View Javadoc

1   package cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages;
2    		
3    		// --- IMPORTS FROM /messages/settings/javasettings/javaimport BEGIN
4   			import java.util.*;import javax.vecmath.*;import cz.cuni.amis.pogamut.base.communication.messages.*;import cz.cuni.amis.pogamut.base.communication.worldview.*;import cz.cuni.amis.pogamut.base.communication.worldview.event.*;import cz.cuni.amis.pogamut.base.communication.worldview.object.*;import cz.cuni.amis.pogamut.multi.communication.worldview.object.*;import cz.cuni.amis.pogamut.base.communication.translator.event.*;import cz.cuni.amis.pogamut.multi.communication.translator.event.*;import cz.cuni.amis.pogamut.base3d.worldview.object.*;import cz.cuni.amis.pogamut.base3d.worldview.object.event.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.*;import cz.cuni.amis.pogamut.ut2004.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004.communication.translator.itemdescriptor.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType.Category;import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;import cz.cuni.amis.utils.exception.*;import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;import cz.cuni.amis.utils.SafeEquals;import cz.cuni.amis.pogamut.base.agent.*;import cz.cuni.amis.pogamut.multi.agent.*;import cz.cuni.amis.pogamut.multi.communication.worldview.property.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.property.*;import cz.cuni.amis.utils.token.*;import cz.cuni.amis.utils.*;
5   		// --- IMPORTS FROM /messages/settings/javasettings/javaimport END
6   		
7   		
8   		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name='all'] BEGIN
9   				
10  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name='all'] END
11  		
12  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=base]+classtype[@name=abstract] BEGIN
13  		
14  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=base]+classtype[@name=abstract] END
15      
16   		/**
17           *  
18              				Abstract definition of the GameBots2004 message NFO.  
19              			
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		Asynchronous message. Sent as response to READY command.
25  		Information about the game. What type of game is it going to be,
26  		number of teams, maximum size of teams etc.
27  	
28           */
29   	public abstract class GameInfo   
30    				extends 
31    				InfoMessage
32    						implements IWorldEvent, IWorldChangeEvent, ICompositeWorldObject
33    						
34  	    {
35   	
36      	/** Example how the message looks like - used during parser tests. */
37      	public static final String PROTOTYPE =
38      		"NFO {Gametype text}  {Level text}  {WeaponStay False}  {TimeLimit 0}  {FragLimit 0}  {GoalTeamScore null}  {MaxTeams 0}  {MaxTeamSize 0}  {RedBaseLocation 0,0,0}  {BlueBaseLocation 0,0,0}  {FirstDomPointLocation 0,0,0}  {SecondDomPointLocation 0,0,0}  {GamePaused False}  {BotsPaused False}  {FactoryLocation 0,0,0}  {FactoryRadius 0}  {DisperserLocation 0,0,0}  {DisperserRadius 0}  {FactoryAdrenalineCount 0}  {FactorySpawnType text} ";
39      
40      	
41      	
42      	/**
43      	 * Parameter-less contructor for the message.
44      	 */
45  		public GameInfo()
46  		{
47  		}
48  	
49  				// abstract message, it does not have any more constructors				
50  			
51  						
52  						public static final UnrealId GameInfoId = UnrealId.get("GameInfoId");
53  					
54  						
55  						public UnrealId getId() {						
56  							return cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo.GameInfoId;
57  						}
58  					
59  	   		
60  			protected long SimTime;
61  				
62  			/**
63  			 * Simulation time in MILLI SECONDS !!!
64  			 */	
65  			@Override
66  			public long getSimTime() {
67  				return SimTime;
68  			}
69  						
70  			/**
71  			 * Used by Yylex to slip correct time of the object or programmatically.
72  			 */
73  			protected void setSimTime(long SimTime) {
74  				this.SimTime = SimTime;
75  			}
76  	   	
77   		/**
78           * 
79  			What you are playing (BotDeathMatch, BotTeamGame,
80  			BotCTFGame,BotDoubleDomination).
81  		 
82           */
83          public abstract String getGametype()
84   	;
85  		    			
86   		/**
87           * Name of map in game. 
88           */
89          public abstract String getLevel()
90   	;
91  		    			
92   		/**
93           * 
94  			If true respawned weapons will stay on the ground after picked up (but bot cannot pickup same weapon twice).
95  		 
96           */
97          public abstract boolean isWeaponStay()
98   	;
99  		    			
100  		/**
101          * 
102 			Maximum time game will last (if tied at end may goe to
103 			"sudden death overtime" - depends on the game type).
104 		 
105          */
106         public abstract double getTimeLimit()
107  	;
108 		    			
109  		/**
110          * 
111 			Number of kills needed to win game (BotDeathMatch only).
112 		 
113          */
114         public abstract int getFragLimit()
115  	;
116 		    			
117  		/**
118          * 
119 			Number of points a team needs to win the game (BotTeamGame,
120 			BotCTFGame, BotDoubleDomination).
121 		 
122          */
123         public abstract long getGoalTeamScore()
124  	;
125 		    			
126  		/**
127          * 
128 			Max number of teams. Valid team range will be 0 to (MaxTeams
129 			- 1) (BotTeamGame, BotCTFGame, BotDoubleDomination). Usually
130 			there will be two teams - 0 and 1.
131 		 
132          */
133         public abstract int getMaxTeams()
134  	;
135 		    			
136  		/**
137          * 
138 			Max number of players per side (BotTeamGame, BotCTFGame,
139 			BotDoubleDomination).
140 		 
141          */
142         public abstract int getMaxTeamSize()
143  	;
144 		    			
145  		/**
146          * 
147 			Location of the base spawning the red flag (team 0) (BotCTFGame).
148 		 
149          */
150         public abstract Location getRedBaseLocation()
151  	;
152 		    			
153  		/**
154          * 
155 			Location of the base spawning the blue flag (team 1) (BotCTFGame).
156 		 
157          */
158         public abstract Location getBlueBaseLocation()
159  	;
160 		    			
161  		/**
162          * 
163 			Location of the first dom point (BotDoubleDomination).
164 		 
165          */
166         public abstract Location getFirstDomPointLocation()
167  	;
168 		    			
169  		/**
170          * 
171 			Location of the second dom point (BotDoubleDomination).
172 		 
173          */
174         public abstract Location getSecondDomPointLocation()
175  	;
176 		    			
177  		/**
178          * 
179 			If the game is paused - nobody can move.
180 		 
181          */
182         public abstract boolean isGamePaused()
183  	;
184 		    			
185  		/**
186          * 
187 			If the game is paused just for bots - human controlled
188 			players can normally move.
189 		 
190          */
191         public abstract boolean isBotsPaused()
192  	;
193 		    			
194  		/**
195          * 
196 			Sent only in BotScenario game type. Location of the factory.
197 		 
198          */
199         public abstract Location getFactoryLocation()
200  	;
201 		    			
202  		/**
203          * 
204 			Sent only in BotScenario game type. Radius of the factory.
205 		 
206          */
207         public abstract double getFactoryRadius()
208  	;
209 		    			
210  		/**
211          * 
212 			Sent only in BotScenario game type. Location of the goal point where UDamagePack should be taken.
213 		 
214          */
215         public abstract Location getDisperserLocation()
216  	;
217 		    			
218  		/**
219          * 
220 			Sent only in BotScenario game type. Radius of the disperser point.
221 		 
222          */
223         public abstract double getDisperserRadius()
224  	;
225 		    			
226  		/**
227          * 
228 			Sent only in BotScenario game type. How much adrenaline we need to activate the factory.
229 		 
230          */
231         public abstract double getFactoryAdrenalineCount()
232  	;
233 		    			
234  		/**
235          * 
236 			Sent only in BotScenario game type. Pickup class our factory spawns when used properly. Item will be spawned at the bot's location.
237 		 
238          */
239         public abstract String getFactorySpawnType()
240  	;
241 		    			
242     	
243     	public static class GameInfoUpdate
244      extends GBObjectUpdate implements ICompositeWorldObjectUpdatedEvent, IGBWorldObjectEvent {	
245 			private GameInfo object;
246 			private long time;
247 			private ITeamId teamId;
248 			
249 			public GameInfoUpdate
250     (GameInfo source, long eventTime, ITeamId teamId) {
251 				this.object = source;
252 				this.time = eventTime;
253 				this.teamId = teamId;
254 			}
255 			
256 			/**
257 			 * Simulation time in MILLI SECONDS !!!
258 			 */ 
259 			@Override
260 			public long getSimTime() {
261 				return time;
262 			}
263 	
264 			@Override
265 			public IWorldObject getObject() {
266 				return object;
267 			}
268 	
269 			@Override
270 			public WorldObjectId getId() {
271 				return object.getId();
272 			}
273 	
274 			@Override
275 			public ILocalWorldObjectUpdatedEvent getLocalEvent() {
276 				return new GameInfoLocalImpl.GameInfoLocalUpdate
277     ((GameInfoLocal)object.getLocal(), time);
278 			}
279 	
280 			@Override
281 			public ISharedWorldObjectUpdatedEvent getSharedEvent() {
282 				return new GameInfoSharedImpl.GameInfoSharedUpdate
283     ((GameInfoShared)object.getShared(), time, teamId);
284 			}
285 	
286 			@Override
287 			public IStaticWorldObjectUpdatedEvent getStaticEvent() {
288 				return new GameInfoStaticImpl.GameInfoStaticUpdate
289     ((GameInfoStatic)object.getStatic(), time);
290 			}
291 			
292 		}
293     
294  		
295  	    public String toString() {
296             return
297             	super.toString() + "[" +
298             	
299 		              			"Gametype = " + String.valueOf(getGametype()
300  	) + " | " + 
301 		              		
302 		              			"Level = " + String.valueOf(getLevel()
303  	) + " | " + 
304 		              		
305 		              			"WeaponStay = " + String.valueOf(isWeaponStay()
306  	) + " | " + 
307 		              		
308 		              			"TimeLimit = " + String.valueOf(getTimeLimit()
309  	) + " | " + 
310 		              		
311 		              			"FragLimit = " + String.valueOf(getFragLimit()
312  	) + " | " + 
313 		              		
314 		              			"GoalTeamScore = " + String.valueOf(getGoalTeamScore()
315  	) + " | " + 
316 		              		
317 		              			"MaxTeams = " + String.valueOf(getMaxTeams()
318  	) + " | " + 
319 		              		
320 		              			"MaxTeamSize = " + String.valueOf(getMaxTeamSize()
321  	) + " | " + 
322 		              		
323 		              			"RedBaseLocation = " + String.valueOf(getRedBaseLocation()
324  	) + " | " + 
325 		              		
326 		              			"BlueBaseLocation = " + String.valueOf(getBlueBaseLocation()
327  	) + " | " + 
328 		              		
329 		              			"FirstDomPointLocation = " + String.valueOf(getFirstDomPointLocation()
330  	) + " | " + 
331 		              		
332 		              			"SecondDomPointLocation = " + String.valueOf(getSecondDomPointLocation()
333  	) + " | " + 
334 		              		
335 		              			"GamePaused = " + String.valueOf(isGamePaused()
336  	) + " | " + 
337 		              		
338 		              			"BotsPaused = " + String.valueOf(isBotsPaused()
339  	) + " | " + 
340 		              		
341 		              			"FactoryLocation = " + String.valueOf(getFactoryLocation()
342  	) + " | " + 
343 		              		
344 		              			"FactoryRadius = " + String.valueOf(getFactoryRadius()
345  	) + " | " + 
346 		              		
347 		              			"DisperserLocation = " + String.valueOf(getDisperserLocation()
348  	) + " | " + 
349 		              		
350 		              			"DisperserRadius = " + String.valueOf(getDisperserRadius()
351  	) + " | " + 
352 		              		
353 		              			"FactoryAdrenalineCount = " + String.valueOf(getFactoryAdrenalineCount()
354  	) + " | " + 
355 		              		
356 		              			"FactorySpawnType = " + String.valueOf(getFactorySpawnType()
357  	) + " | " + 
358 		              		
359 				"]";           		
360         }
361  	
362  		
363  		public String toHtmlString() {
364  			return super.toString() + "[<br/>" +
365             	
366 		              			"<b>Gametype</b> = " + String.valueOf(getGametype()
367  	) + " <br/> " + 
368 		              		
369 		              			"<b>Level</b> = " + String.valueOf(getLevel()
370  	) + " <br/> " + 
371 		              		
372 		              			"<b>WeaponStay</b> = " + String.valueOf(isWeaponStay()
373  	) + " <br/> " + 
374 		              		
375 		              			"<b>TimeLimit</b> = " + String.valueOf(getTimeLimit()
376  	) + " <br/> " + 
377 		              		
378 		              			"<b>FragLimit</b> = " + String.valueOf(getFragLimit()
379  	) + " <br/> " + 
380 		              		
381 		              			"<b>GoalTeamScore</b> = " + String.valueOf(getGoalTeamScore()
382  	) + " <br/> " + 
383 		              		
384 		              			"<b>MaxTeams</b> = " + String.valueOf(getMaxTeams()
385  	) + " <br/> " + 
386 		              		
387 		              			"<b>MaxTeamSize</b> = " + String.valueOf(getMaxTeamSize()
388  	) + " <br/> " + 
389 		              		
390 		              			"<b>RedBaseLocation</b> = " + String.valueOf(getRedBaseLocation()
391  	) + " <br/> " + 
392 		              		
393 		              			"<b>BlueBaseLocation</b> = " + String.valueOf(getBlueBaseLocation()
394  	) + " <br/> " + 
395 		              		
396 		              			"<b>FirstDomPointLocation</b> = " + String.valueOf(getFirstDomPointLocation()
397  	) + " <br/> " + 
398 		              		
399 		              			"<b>SecondDomPointLocation</b> = " + String.valueOf(getSecondDomPointLocation()
400  	) + " <br/> " + 
401 		              		
402 		              			"<b>GamePaused</b> = " + String.valueOf(isGamePaused()
403  	) + " <br/> " + 
404 		              		
405 		              			"<b>BotsPaused</b> = " + String.valueOf(isBotsPaused()
406  	) + " <br/> " + 
407 		              		
408 		              			"<b>FactoryLocation</b> = " + String.valueOf(getFactoryLocation()
409  	) + " <br/> " + 
410 		              		
411 		              			"<b>FactoryRadius</b> = " + String.valueOf(getFactoryRadius()
412  	) + " <br/> " + 
413 		              		
414 		              			"<b>DisperserLocation</b> = " + String.valueOf(getDisperserLocation()
415  	) + " <br/> " + 
416 		              		
417 		              			"<b>DisperserRadius</b> = " + String.valueOf(getDisperserRadius()
418  	) + " <br/> " + 
419 		              		
420 		              			"<b>FactoryAdrenalineCount</b> = " + String.valueOf(getFactoryAdrenalineCount()
421  	) + " <br/> " + 
422 		              		
423 		              			"<b>FactorySpawnType</b> = " + String.valueOf(getFactorySpawnType()
424  	) + " <br/> " + 
425 		              		
426 				"<br/>]";     
427 		}
428  	 
429  	    public String toJsonLiteral() {
430             return "GameInfo(null, "
431             		
432                    + ")";
433         }
434  	
435  		
436  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
437         	
438 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
439 		
440 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---
441 	        
442 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---        	            	
443  	
444 		}
445