1
2 /**
3 IMPORTANT !!!
4
5 DO NOT EDIT THIS FILE. IT IS GENERATED FROM approriate xml file in xmlresources/gbinfomessages BY
6 THE JavaClassesGenerator.xslt. MODIFY THESE FILES INSTEAD OF THIS ONE.
7
8 IMPORTANT END !!!
9 */
10 package
11 cz.cuni.amis.pogamut.udk.communication.messages.gbinfomessages;
12 import java.util.*;
13 import javax.vecmath.*;
14 import cz.cuni.amis.pogamut.base.communication.messages.*;
15 import cz.cuni.amis.pogamut.base.communication.worldview.*;
16 import cz.cuni.amis.pogamut.base.communication.worldview.event.*;
17 import cz.cuni.amis.pogamut.base.communication.worldview.object.*;
18 import cz.cuni.amis.pogamut.base.communication.translator.event.*;
19 import cz.cuni.amis.pogamut.base3d.worldview.object.*;
20 import cz.cuni.amis.pogamut.base3d.worldview.object.event.*;
21 import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
22 import cz.cuni.amis.pogamut.udk.communication.messages.*;
23 import cz.cuni.amis.pogamut.udk.communication.worldview.objects.*;
24 import cz.cuni.amis.pogamut.udk.communication.translator.itemdescriptor.*;
25 import cz.cuni.amis.pogamut.udk.communication.messages.ItemType.Category;
26 import cz.cuni.amis.utils.exception.*;
27 import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;
28 import cz.cuni.amis.utils.SafeEquals;
29 import cz.cuni.amis.pogamut.multi.communication.worldview.object.*;
30
31
32 /**
33
34 Asynchronous message. Sent as response to READY command.
35 Information about the game. What type of game is it going to be,
36 number of teams, maximum size of teams etc.
37
38 Corresponding GameBots message is
39 NFO.
40
41 */
42
43 public class
44 GameInfo
45 extends GBObjectUpdate
46
47 implements IGBWorldObjectEvent, IWorldObject
48
49 {
50
51 /**
52 Creates new instance of command GameInfo.
53
54 Asynchronous message. Sent as response to READY command.
55 Information about the game. What type of game is it going to be,
56 number of teams, maximum size of teams etc.
57 Corresponding GameBots message for this command is
58 .
59 @param Gametype
60 What you are playing (BotDeathMatch, BotTeamGame,
61 BotCTFGame).
62
63 @param Level Name of map in game.
64 @param WeaponStay
65 If true respawned weapons will stay on the ground after picked up (but bot cannot pickup same weapon twice).
66
67 @param TimeLimit
68 Maximum time game will last (if tied at end may goe to
69 "sudden death overtime" - depends on the game type).
70
71 @param FragLimit
72 Number of kills needed to win game (BotDeathMatch only).
73
74 @param GoalTeamScore
75 Number of points a team needs to win the game (BotTeamGame,
76 BotCTFGame).
77
78 @param MaxTeams
79 Max number of teams. Valid team range will be 0 to (MaxTeams
80 - 1) (BotTeamGame, BotCTFGame). Usually
81 there will be two teams - 0 and 1.
82
83 @param MaxTeamSize
84 Max number of players per side (BotTeamGame, BotCTFGame).
85
86 @param RedBaseLocation
87 Location of the base spawning the red flag (team 0) (BotCTFGame).
88
89 @param BlueBaseLocation
90 Location of the base spawning the blue flag (team 1) (BotCTFGame).
91
92 @param GamePaused
93 If the game is paused - nobody can move.
94
95 @param BotsPaused
96 If the game is paused just for bots - human controlled
97 players can normally move.
98
99 */
100 public GameInfo(
101 String Gametype, String Level, boolean WeaponStay, double TimeLimit, int FragLimit, double GoalTeamScore, int MaxTeams, int MaxTeamSize, Location RedBaseLocation, Location BlueBaseLocation, boolean GamePaused, boolean BotsPaused) {
102
103 this.Gametype = Gametype;
104
105 this.Level = Level;
106
107 this.WeaponStay = WeaponStay;
108
109 this.TimeLimit = TimeLimit;
110
111 this.FragLimit = FragLimit;
112
113 this.GoalTeamScore = GoalTeamScore;
114
115 this.MaxTeams = MaxTeams;
116
117 this.MaxTeamSize = MaxTeamSize;
118
119 this.RedBaseLocation = RedBaseLocation;
120
121 this.BlueBaseLocation = BlueBaseLocation;
122
123 this.GamePaused = GamePaused;
124
125 this.BotsPaused = BotsPaused;
126
127 }
128
129
130 /** Example how the message looks like - used during parser tests. */
131 public static final String PROTOTYPE =
132 "NFO {Gametype text} {Level text} {WeaponStay False} {TimeLimit 0} {FragLimit 0} {GoalTeamScore 0} {MaxTeams 0} {MaxTeamSize 0} {RedBaseLocation 0,0,0} {BlueBaseLocation 0,0,0} {GamePaused False} {BotsPaused False}";
133
134
135 /////// Properties BEGIN
136
137 /**
138
139 What you are playing (BotDeathMatch, BotTeamGame,
140 BotCTFGame).
141 */
142 protected
143 String Gametype =
144 null;
145
146
147 /**
148
149 What you are playing (BotDeathMatch, BotTeamGame,
150 BotCTFGame).
151 */
152 public
153 String getGametype() {
154 return
155 Gametype;
156 }
157
158
159
160 /**
161 Name of map in game. */
162 protected
163 String Level =
164 null;
165
166
167 /**
168 Name of map in game. */
169 public
170 String getLevel() {
171 return
172 Level;
173 }
174
175
176
177 /**
178
179 If true respawned weapons will stay on the ground after picked up (but bot cannot pickup same weapon twice).
180 */
181 protected
182 boolean WeaponStay =
183 false;
184
185
186 /**
187
188 If true respawned weapons will stay on the ground after picked up (but bot cannot pickup same weapon twice).
189 */
190 public
191 boolean isWeaponStay() {
192 return
193 WeaponStay;
194 }
195
196
197
198 /**
199
200 Maximum time game will last (if tied at end may goe to
201 "sudden death overtime" - depends on the game type).
202 */
203 protected
204 double TimeLimit =
205 0;
206
207
208 /**
209
210 Maximum time game will last (if tied at end may goe to
211 "sudden death overtime" - depends on the game type).
212 */
213 public
214 double getTimeLimit() {
215 return
216 TimeLimit;
217 }
218
219
220
221 /**
222
223 Number of kills needed to win game (BotDeathMatch only).
224 */
225 protected
226 int FragLimit =
227 0;
228
229
230 /**
231
232 Number of kills needed to win game (BotDeathMatch only).
233 */
234 public
235 int getFragLimit() {
236 return
237 FragLimit;
238 }
239
240
241
242 /**
243
244 Number of points a team needs to win the game (BotTeamGame,
245 BotCTFGame).
246 */
247 protected
248 double GoalTeamScore =
249 0;
250
251
252 /**
253
254 Number of points a team needs to win the game (BotTeamGame,
255 BotCTFGame).
256 */
257 public
258 double getGoalTeamScore() {
259 return
260 GoalTeamScore;
261 }
262
263
264
265 /**
266
267 Max number of teams. Valid team range will be 0 to (MaxTeams
268 - 1) (BotTeamGame, BotCTFGame). Usually
269 there will be two teams - 0 and 1.
270 */
271 protected
272 int MaxTeams =
273 0;
274
275
276 /**
277
278 Max number of teams. Valid team range will be 0 to (MaxTeams
279 - 1) (BotTeamGame, BotCTFGame). Usually
280 there will be two teams - 0 and 1.
281 */
282 public
283 int getMaxTeams() {
284 return
285 MaxTeams;
286 }
287
288
289
290 /**
291
292 Max number of players per side (BotTeamGame, BotCTFGame).
293 */
294 protected
295 int MaxTeamSize =
296 0;
297
298
299 /**
300
301 Max number of players per side (BotTeamGame, BotCTFGame).
302 */
303 public
304 int getMaxTeamSize() {
305 return
306 MaxTeamSize;
307 }
308
309
310
311 /**
312
313 Location of the base spawning the red flag (team 0) (BotCTFGame).
314 */
315 protected
316 Location RedBaseLocation =
317 null;
318
319
320 /**
321
322 Location of the base spawning the red flag (team 0) (BotCTFGame).
323 */
324 public
325 Location getRedBaseLocation() {
326 return
327 RedBaseLocation;
328 }
329
330
331
332 /**
333
334 Location of the base spawning the blue flag (team 1) (BotCTFGame).
335 */
336 protected
337 Location BlueBaseLocation =
338 null;
339
340
341 /**
342
343 Location of the base spawning the blue flag (team 1) (BotCTFGame).
344 */
345 public
346 Location getBlueBaseLocation() {
347 return
348 BlueBaseLocation;
349 }
350
351
352
353 /**
354
355 If the game is paused - nobody can move.
356 */
357 protected
358 boolean GamePaused =
359 false;
360
361
362 /**
363
364 If the game is paused - nobody can move.
365 */
366 public
367 boolean isGamePaused() {
368 return
369 GamePaused;
370 }
371
372
373
374 /**
375
376 If the game is paused just for bots - human controlled
377 players can normally move.
378 */
379 protected
380 boolean BotsPaused =
381 false;
382
383
384 /**
385
386 If the game is paused just for bots - human controlled
387 players can normally move.
388 */
389 public
390 boolean isBotsPaused() {
391 return
392 BotsPaused;
393 }
394
395
396
397 /////// Properties END
398
399 /////// Extra Java code BEGIN
400
401 /////// Additional code from xslt BEGIN
402
403 public static final UnrealId GameInfoId = UnrealId.get("GameInfoId");
404
405 public UnrealId getId() {
406 return GameInfoId;
407 }
408
409 protected double Time = 0;
410
411 protected double getTime() {
412 return Time;
413 }
414
415 protected void setTime(double time) {
416 this.Time = time;
417 }
418
419 public double getLastSeenTime() {
420 return Time;
421 }
422
423
424 public ILocalWorldObject getLocal() {
425 return null;
426 }
427
428 public ISharedWorldObject getShared() {
429 return null;
430 }
431
432 public IStaticWorldObject getStatic() {
433 return null;
434 }
435
436 @Override
437 public long getSimTime() {
438 return (long)getLastSeenTime();
439 }
440
441 public boolean equals(Object obj) {
442 if (!(obj instanceof GameInfo)) return false;
443 GameInfo cast = (GameInfo)obj;
444 if (this.getId() != null) return this.getId().equals(cast.getId());
445 else return cast.getId() == null;
446 }
447
448 public int hashCode() {
449 if (getId() != null) return getId().hashCode();
450 return 0;
451 }
452
453
454
455
456 /////// Additional code from xslt END
457
458 /////// Extra Java from XML BEGIN
459
460 /////// Extra Java from XML END
461
462 /////// Extra Java code END
463
464
465
466 /**
467 * Cloning constructor.
468 */
469 public GameInfo(GameInfo original) {
470
471 this.Gametype=original.Gametype;
472
473 this.Level=original.Level;
474
475 this.WeaponStay=original.WeaponStay;
476
477 this.TimeLimit=original.TimeLimit;
478
479 this.FragLimit=original.FragLimit;
480
481 this.GoalTeamScore=original.GoalTeamScore;
482
483 this.MaxTeams=original.MaxTeams;
484
485 this.MaxTeamSize=original.MaxTeamSize;
486
487 this.RedBaseLocation=original.RedBaseLocation;
488
489 this.BlueBaseLocation=original.BlueBaseLocation;
490
491 this.GamePaused=original.GamePaused;
492
493 this.BotsPaused=original.BotsPaused;
494
495 }
496
497
498 /**
499 * Used by Yylex to create empty message then to fill it's protected fields (Yylex is in the same package).
500 */
501 public GameInfo() {
502 }
503
504
505 /**
506 * Here we save the original object for which this object is an update.
507 */
508 private IWorldObject orig = null;
509
510 public IWorldObjectUpdateResult update(IWorldObject obj) {
511 if(obj == null) {
512 orig = this;
513 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.CREATED, this);
514 }
515 orig = obj;
516 // typecast
517 GameInfo o = (GameInfo)obj;
518
519 boolean updated = false;
520
521
522 if (!SafeEquals.equals(o.Level, Level)) {
523 o.Level=Level;
524 updated = true;
525 }
526
527 if (o.WeaponStay != WeaponStay) {
528 o.WeaponStay=WeaponStay;
529 updated = true;
530 }
531
532 if (o.TimeLimit != TimeLimit) {
533 o.TimeLimit=TimeLimit;
534 updated = true;
535 }
536
537 if (o.GamePaused != GamePaused) {
538 o.GamePaused=GamePaused;
539 updated = true;
540 }
541
542 if (o.BotsPaused != BotsPaused) {
543 o.BotsPaused=BotsPaused;
544 updated = true;
545 }
546
547 o.Time = Time;
548
549
550 if (updated) {
551 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.UPDATED, o);
552 } else {
553 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.SAME, o);
554 }
555 }
556
557 /**
558 * Returns original object (if method update() has already been called, for bot-programmer that is always true
559 * as the original object is updated and then the event is propagated).
560 */
561 public IWorldObject getObject() {
562 if (orig == null) return this;
563 return orig;
564 }
565
566
567
568 public String toString() {
569 return
570
571 super.toString() + " | " +
572
573 "Gametype = " +
574 String.valueOf(Gametype) + " | " +
575
576 "Level = " +
577 String.valueOf(Level) + " | " +
578
579 "WeaponStay = " +
580 String.valueOf(WeaponStay) + " | " +
581
582 "TimeLimit = " +
583 String.valueOf(TimeLimit) + " | " +
584
585 "FragLimit = " +
586 String.valueOf(FragLimit) + " | " +
587
588 "GoalTeamScore = " +
589 String.valueOf(GoalTeamScore) + " | " +
590
591 "MaxTeams = " +
592 String.valueOf(MaxTeams) + " | " +
593
594 "MaxTeamSize = " +
595 String.valueOf(MaxTeamSize) + " | " +
596
597 "RedBaseLocation = " +
598 String.valueOf(RedBaseLocation) + " | " +
599
600 "BlueBaseLocation = " +
601 String.valueOf(BlueBaseLocation) + " | " +
602
603 "GamePaused = " +
604 String.valueOf(GamePaused) + " | " +
605
606 "BotsPaused = " +
607 String.valueOf(BotsPaused) + " | " +
608 "";
609
610 }
611
612 public String toHtmlString() {
613 return super.toString() +
614
615 "<b>Gametype</b> : " +
616 String.valueOf(Gametype) +
617 " <br/> " +
618
619 "<b>Level</b> : " +
620 String.valueOf(Level) +
621 " <br/> " +
622
623 "<b>WeaponStay</b> : " +
624 String.valueOf(WeaponStay) +
625 " <br/> " +
626
627 "<b>TimeLimit</b> : " +
628 String.valueOf(TimeLimit) +
629 " <br/> " +
630
631 "<b>FragLimit</b> : " +
632 String.valueOf(FragLimit) +
633 " <br/> " +
634
635 "<b>GoalTeamScore</b> : " +
636 String.valueOf(GoalTeamScore) +
637 " <br/> " +
638
639 "<b>MaxTeams</b> : " +
640 String.valueOf(MaxTeams) +
641 " <br/> " +
642
643 "<b>MaxTeamSize</b> : " +
644 String.valueOf(MaxTeamSize) +
645 " <br/> " +
646
647 "<b>RedBaseLocation</b> : " +
648 String.valueOf(RedBaseLocation) +
649 " <br/> " +
650
651 "<b>BlueBaseLocation</b> : " +
652 String.valueOf(BlueBaseLocation) +
653 " <br/> " +
654
655 "<b>GamePaused</b> : " +
656 String.valueOf(GamePaused) +
657 " <br/> " +
658
659 "<b>BotsPaused</b> : " +
660 String.valueOf(BotsPaused) +
661 " <br/> " +
662 "";
663 }
664
665
666
667 }
668
669