@@ -13,8 +13,6 @@ class GameEvent(Event):
13
13
"""
14
14
This is the base class for all game events. The attributes below are universally available.
15
15
"""
16
- name = 'GameEvent'
17
-
18
16
def __init__ (self , frame , pid ):
19
17
#: The id of the player generating the event. This is 16 for global non-player events.
20
18
#: Prior to Heart of the Swarm this was the player id. Since HotS it is
@@ -34,6 +32,9 @@ def __init__(self, frame, pid):
34
32
#: A flag indicating if it is a local or global event.
35
33
self .is_local = (pid != 16 )
36
34
35
+ #: Short cut string for event class name
36
+ self .name = self .__class__ .__name__
37
+
37
38
def _str_prefix (self ):
38
39
player_name = self .player .name if getattr (self , 'pid' , 16 ) != 16 else "Global"
39
40
return "%s\t %-15s " % (Length (seconds = int (self .frame / 16 )), player_name )
@@ -47,9 +48,6 @@ class GameStartEvent(GameEvent):
47
48
Recorded when the game starts and the frames start to roll. This is a global non-player
48
49
event.
49
50
"""
50
-
51
- name = 'GameStartEvent'
52
-
53
51
def __init__ (self , frame , pid , data ):
54
52
super (GameStartEvent , self ).__init__ (frame , pid )
55
53
@@ -58,9 +56,6 @@ class PlayerLeaveEvent(GameEvent):
58
56
"""
59
57
Recorded when a player leaves the game.
60
58
"""
61
-
62
- name = 'PlayerLeaveEvent'
63
-
64
59
def __init__ (self , frame , pid , data ):
65
60
super (PlayerLeaveEvent , self ).__init__ (frame , pid )
66
61
@@ -70,9 +65,6 @@ class UserOptionsEvent(GameEvent):
70
65
This event is recorded for each player at the very beginning of the game before the
71
66
:class:`GameStartEvent`.
72
67
"""
73
-
74
- name = 'UserOptionsEvent'
75
-
76
68
def __init__ (self , frame , pid , data ):
77
69
super (UserOptionsEvent , self ).__init__ (frame , pid )
78
70
#:
@@ -118,12 +110,8 @@ def create_command_event(frame, pid, data):
118
110
return SelfAbilityEvent (frame , pid , data )
119
111
120
112
121
- class PlayerActionEvent (GameEvent ):
122
- name = 'PlayerActionEvent'
123
-
124
-
125
113
@loggable
126
- class AbilityEvent (PlayerActionEvent ):
114
+ class AbilityEvent (GameEvent ):
127
115
"""
128
116
Ability events are generated when ever a player in the game issues a command
129
117
to a unit or group of units. They are split into three subclasses of ability,
@@ -133,11 +121,6 @@ class AbilityEvent(PlayerActionEvent):
133
121
See :class:`LocationAbilityEvent`, :class:`TargetAbilityEvent`, and :class:`SelfAbilityEvent`
134
122
for individual details.
135
123
"""
136
-
137
- name = 'AbilityEvent'
138
-
139
- is_player_action = True
140
-
141
124
def __init__ (self , frame , pid , data ):
142
125
super (AbilityEvent , self ).__init__ (frame , pid )
143
126
@@ -236,9 +219,6 @@ class LocationAbilityEvent(AbilityEvent):
236
219
Note that like all AbilityEvents, the event will be recorded regardless
237
220
of whether or not the command was successful.
238
221
"""
239
-
240
- name = 'LocationAbilityEvent'
241
-
242
222
def __init__ (self , frame , pid , data ):
243
223
super (LocationAbilityEvent , self ).__init__ (frame , pid , data )
244
224
@@ -265,9 +245,6 @@ class TargetAbilityEvent(AbilityEvent):
265
245
266
246
Note that all AbilityEvents are recorded regardless of whether or not the command was successful.
267
247
"""
268
-
269
- name = 'TargetAbilityEvent'
270
-
271
248
def __init__ (self , frame , pid , data ):
272
249
super (TargetAbilityEvent , self ).__init__ (frame , pid , data )
273
250
@@ -318,9 +295,6 @@ class SelfAbilityEvent(AbilityEvent):
318
295
319
296
Note that all AbilityEvents are recorded regardless of whether or not the command was successful.
320
297
"""
321
-
322
- name = 'SelfAbilityEvent'
323
-
324
298
def __init__ (self , frame , pid , data ):
325
299
super (SelfAbilityEvent , self ).__init__ (frame , pid , data )
326
300
@@ -329,7 +303,7 @@ def __init__(self, frame, pid, data):
329
303
330
304
331
305
@loggable
332
- class SelectionEvent (PlayerActionEvent ):
306
+ class SelectionEvent (GameEvent ):
333
307
"""
334
308
Selection events are generated when ever the active selection of the
335
309
player is updated. Unlike other game events, these events can also be
@@ -340,10 +314,6 @@ class SelectionEvent(PlayerActionEvent):
340
314
by non-player actions. When a player action updates a control group
341
315
a :class:`HotkeyEvent` is generated.
342
316
"""
343
-
344
- name = 'SelectionEvent'
345
- is_player_action = True
346
-
347
317
def __init__ (self , frame , pid , data ):
348
318
super (SelectionEvent , self ).__init__ (frame , pid )
349
319
@@ -392,39 +362,32 @@ def __str__(self):
392
362
def create_control_group_event (frame , pid , data ):
393
363
update_type = data ['control_group_update' ]
394
364
if update_type == 0 :
395
- return SetToHotkeyEvent (frame , pid , data )
365
+ return SetControlGroupEvent (frame , pid , data )
396
366
elif update_type == 1 :
397
- return AddToHotkeyEvent (frame , pid , data )
367
+ return AddToControlGroupEvent (frame , pid , data )
398
368
elif update_type == 2 :
399
- return GetFromHotkeyEvent (frame , pid , data )
369
+ return GetControlGroupEvent (frame , pid , data )
400
370
elif update_type == 3 :
401
371
# TODO: What could this be?!?
402
- return HotkeyEvent (frame , pid , data )
372
+ return ControlGroupEvent (frame , pid , data )
403
373
404
374
405
375
@loggable
406
- class HotkeyEvent ( PlayerActionEvent ):
376
+ class ControlGroupEvent ( GameEvent ):
407
377
"""
408
- Hotkey events are recorded when ever a player action modifies a control
409
- group. I know that calling control group events hotkey events doesn't make
410
- sense but for backwards compatibility I haven't changed it yet. Sorry.
411
-
412
- There are three kinds of hotkey events, generated by each of the possible
378
+ ControlGroup events are recorded when ever a player action modifies or accesses a control
379
+ group. There are three kinds of events, generated by each of the possible
413
380
player actions:
414
381
415
- * :class:`SetToHotkeyEvent ` - Recorded when a user sets a control group (ctrl+#).
416
- * :class:`GetFromHotkeyEvent ` - Recorded when a user retrieves a control group (#).
417
- * :class:`AddToHotkeyEvent ` - Recorded when a user adds to a control group (shift+ctrl+#)
382
+ * :class:`SetControlGroup ` - Recorded when a user sets a control group (ctrl+#).
383
+ * :class:`GetControlGroup ` - Recorded when a user retrieves a control group (#).
384
+ * :class:`AddToControlGroup ` - Recorded when a user adds to a control group (shift+ctrl+#)
418
385
419
386
All three events have the same set of data (shown below) but are interpretted differently.
420
387
See the class entry for details.
421
388
"""
422
-
423
- name = 'HotkeyEvent'
424
- is_player_action = True
425
-
426
389
def __init__ (self , frame , pid , data ):
427
- super (HotkeyEvent , self ).__init__ (frame , pid )
390
+ super (ControlGroupEvent , self ).__init__ (frame , pid )
428
391
429
392
#: Index to the control group being modified
430
393
self .control_group = data ['control_group_index' ]
@@ -445,38 +408,33 @@ def __init__(self, frame, pid, data):
445
408
self .mask_data = data ['remove_mask' ][1 ]
446
409
447
410
448
- class SetToHotkeyEvent ( HotkeyEvent ):
411
+ class SetControlGroupEvent ( ControlGroupEvent ):
449
412
"""
450
- Extends :class:`HotkeyEvent `
413
+ Extends :class:`ControlGroupEvent `
451
414
452
415
This event does a straight forward replace of the current control group contents
453
416
with the player's current selection. This event doesn't have masks set.
454
417
"""
455
418
456
- name = 'SetToHotkeyEvent'
457
419
458
-
459
- class AddToHotkeyEvent (HotkeyEvent ):
420
+ class AddToControlGroupEvent (SetControlGroupEvent ):
460
421
"""
461
- Extends :class:`HotkeyEvent `
422
+ Extends :class:`ControlGroupEvent `
462
423
463
424
This event adds the current selection to the control group.
464
425
"""
465
426
466
- name = 'AddToHotkeyEvent'
467
-
468
427
469
- class GetFromHotkeyEvent ( HotkeyEvent ):
428
+ class GetControlGroupEvent ( ControlGroupEvent ):
470
429
"""
471
- Extends :class:`HotkeyEvent`
430
+ Extends :class:`ControlGroupEvent`
431
+
472
432
This event replaces the current selection with the contents of the control group.
473
433
The mask data is used to limit that selection to units that are currently selectable.
474
434
You might have 1 medivac and 8 marines on the control group but if the 8 marines are
475
435
inside the medivac they cannot be part of your selection.
476
436
"""
477
437
478
- name = 'GetFromHotkeyEvent'
479
-
480
438
481
439
@loggable
482
440
class CameraEvent (GameEvent ):
@@ -485,9 +443,6 @@ class CameraEvent(GameEvent):
485
443
It does not matter why the camera changed, this event simply records the current
486
444
state of the camera after changing.
487
445
"""
488
-
489
- name = 'CameraEvent'
490
-
491
446
def __init__ (self , frame , pid , data ):
492
447
super (CameraEvent , self ).__init__ (frame , pid )
493
448
@@ -515,8 +470,10 @@ def __str__(self):
515
470
516
471
@loggable
517
472
class ResourceTradeEvent (GameEvent ):
518
- name = 'ResourceTradeEvent'
519
-
473
+ """
474
+ Generated when a player trades resources with another player. But not when fullfulling
475
+ resource requests.
476
+ """
520
477
def __init__ (self , frame , pid , data ):
521
478
super (ResourceTradeEvent , self ).__init__ (frame , pid )
522
479
@@ -552,8 +509,9 @@ def __str__(self):
552
509
553
510
554
511
class ResourceRequestEvent (GameEvent ):
555
- name = 'ResourceRequestEvent'
556
-
512
+ """
513
+ Generated when a player creates a resource request.
514
+ """
557
515
def __init__ (self , frame , pid , data ):
558
516
super (ResourceRequestEvent , self ).__init__ (frame , pid )
559
517
@@ -577,8 +535,9 @@ def __str__(self):
577
535
578
536
579
537
class ResourceRequestFulfillEvent (GameEvent ):
580
- name = 'ResourceRequestFulfillEvent'
581
-
538
+ """
539
+ Generated when a player accepts a resource request.
540
+ """
582
541
def __init__ (self , frame , pid , data ):
583
542
super (ResourceRequestFulfillEvent , self ).__init__ (frame , pid )
584
543
@@ -587,8 +546,9 @@ def __init__(self, frame, pid, data):
587
546
588
547
589
548
class ResourceRequestCancelEvent (GameEvent ):
590
- name = 'ResourceRequestCancelEvent'
591
-
549
+ """
550
+ Generated when a player cancels their resource request.
551
+ """
592
552
def __init__ (self , frame , pid , data ):
593
553
super (ResourceRequestCancelEvent , self ).__init__ (frame , pid )
594
554
0 commit comments