1
2
3
4
5
6
7
8
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
35
36
37
38
39
40
41
42
43 public class
44 GameInfo
45 extends GBObjectUpdate
46
47 implements IGBWorldObjectEvent, IWorldObject
48
49 {
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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
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
136
137
138
139
140
141
142 protected
143 String Gametype =
144 null;
145
146
147
148
149
150
151
152 public
153 String getGametype() {
154 return
155 Gametype;
156 }
157
158
159
160
161
162 protected
163 String Level =
164 null;
165
166
167
168
169 public
170 String getLevel() {
171 return
172 Level;
173 }
174
175
176
177
178
179
180
181 protected
182 boolean WeaponStay =
183 false;
184
185
186
187
188
189
190 public
191 boolean isWeaponStay() {
192 return
193 WeaponStay;
194 }
195
196
197
198
199
200
201
202
203 protected
204 double TimeLimit =
205 0;
206
207
208
209
210
211
212
213 public
214 double getTimeLimit() {
215 return
216 TimeLimit;
217 }
218
219
220
221
222
223
224
225 protected
226 int FragLimit =
227 0;
228
229
230
231
232
233
234 public
235 int getFragLimit() {
236 return
237 FragLimit;
238 }
239
240
241
242
243
244
245
246
247 protected
248 double GoalTeamScore =
249 0;
250
251
252
253
254
255
256
257 public
258 double getGoalTeamScore() {
259 return
260 GoalTeamScore;
261 }
262
263
264
265
266
267
268
269
270
271 protected
272 int MaxTeams =
273 0;
274
275
276
277
278
279
280
281
282 public
283 int getMaxTeams() {
284 return
285 MaxTeams;
286 }
287
288
289
290
291
292
293
294 protected
295 int MaxTeamSize =
296 0;
297
298
299
300
301
302
303 public
304 int getMaxTeamSize() {
305 return
306 MaxTeamSize;
307 }
308
309
310
311
312
313
314
315 protected
316 Location RedBaseLocation =
317 null;
318
319
320
321
322
323
324 public
325 Location getRedBaseLocation() {
326 return
327 RedBaseLocation;
328 }
329
330
331
332
333
334
335
336 protected
337 Location BlueBaseLocation =
338 null;
339
340
341
342
343
344
345 public
346 Location getBlueBaseLocation() {
347 return
348 BlueBaseLocation;
349 }
350
351
352
353
354
355
356
357 protected
358 boolean GamePaused =
359 false;
360
361
362
363
364
365
366 public
367 boolean isGamePaused() {
368 return
369 GamePaused;
370 }
371
372
373
374
375
376
377
378
379 protected
380 boolean BotsPaused =
381 false;
382
383
384
385
386
387
388
389 public
390 boolean isBotsPaused() {
391 return
392 BotsPaused;
393 }
394
395
396
397
398
399
400
401
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
457
458
459
460
461
462
463
464
465
466
467
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
500
501 public GameInfo() {
502 }
503
504
505
506
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
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
559
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