@@ -13,8 +13,6 @@ class GameEvent(Event):
1313 """
1414 This is the base class for all game events. The attributes below are universally available.
1515 """
16- name = 'GameEvent'
17-
1816 def __init__ (self , frame , pid ):
1917 #: The id of the player generating the event. This is 16 for global non-player events.
2018 #: Prior to Heart of the Swarm this was the player id. Since HotS it is
@@ -34,6 +32,9 @@ def __init__(self, frame, pid):
3432 #: A flag indicating if it is a local or global event.
3533 self .is_local = (pid != 16 )
3634
35+ #: Short cut string for event class name
36+ self .name = self .__class__ .__name__
37+
3738 def _str_prefix (self ):
3839 player_name = self .player .name if getattr (self , 'pid' , 16 ) != 16 else "Global"
3940 return "%s\t %-15s " % (Length (seconds = int (self .frame / 16 )), player_name )
@@ -47,9 +48,6 @@ class GameStartEvent(GameEvent):
4748 Recorded when the game starts and the frames start to roll. This is a global non-player
4849 event.
4950 """
50-
51- name = 'GameStartEvent'
52-
5351 def __init__ (self , frame , pid , data ):
5452 super (GameStartEvent , self ).__init__ (frame , pid )
5553
@@ -58,9 +56,6 @@ class PlayerLeaveEvent(GameEvent):
5856 """
5957 Recorded when a player leaves the game.
6058 """
61-
62- name = 'PlayerLeaveEvent'
63-
6459 def __init__ (self , frame , pid , data ):
6560 super (PlayerLeaveEvent , self ).__init__ (frame , pid )
6661
@@ -70,9 +65,6 @@ class UserOptionsEvent(GameEvent):
7065 This event is recorded for each player at the very beginning of the game before the
7166 :class:`GameStartEvent`.
7267 """
73-
74- name = 'UserOptionsEvent'
75-
7668 def __init__ (self , frame , pid , data ):
7769 super (UserOptionsEvent , self ).__init__ (frame , pid )
7870 #:
@@ -118,12 +110,8 @@ def create_command_event(frame, pid, data):
118110 return SelfAbilityEvent (frame , pid , data )
119111
120112
121- class PlayerActionEvent (GameEvent ):
122- name = 'PlayerActionEvent'
123-
124-
125113@loggable
126- class AbilityEvent (PlayerActionEvent ):
114+ class AbilityEvent (GameEvent ):
127115 """
128116 Ability events are generated when ever a player in the game issues a command
129117 to a unit or group of units. They are split into three subclasses of ability,
@@ -133,11 +121,6 @@ class AbilityEvent(PlayerActionEvent):
133121 See :class:`LocationAbilityEvent`, :class:`TargetAbilityEvent`, and :class:`SelfAbilityEvent`
134122 for individual details.
135123 """
136-
137- name = 'AbilityEvent'
138-
139- is_player_action = True
140-
141124 def __init__ (self , frame , pid , data ):
142125 super (AbilityEvent , self ).__init__ (frame , pid )
143126
@@ -236,9 +219,6 @@ class LocationAbilityEvent(AbilityEvent):
236219 Note that like all AbilityEvents, the event will be recorded regardless
237220 of whether or not the command was successful.
238221 """
239-
240- name = 'LocationAbilityEvent'
241-
242222 def __init__ (self , frame , pid , data ):
243223 super (LocationAbilityEvent , self ).__init__ (frame , pid , data )
244224
@@ -265,9 +245,6 @@ class TargetAbilityEvent(AbilityEvent):
265245
266246 Note that all AbilityEvents are recorded regardless of whether or not the command was successful.
267247 """
268-
269- name = 'TargetAbilityEvent'
270-
271248 def __init__ (self , frame , pid , data ):
272249 super (TargetAbilityEvent , self ).__init__ (frame , pid , data )
273250
@@ -318,9 +295,6 @@ class SelfAbilityEvent(AbilityEvent):
318295
319296 Note that all AbilityEvents are recorded regardless of whether or not the command was successful.
320297 """
321-
322- name = 'SelfAbilityEvent'
323-
324298 def __init__ (self , frame , pid , data ):
325299 super (SelfAbilityEvent , self ).__init__ (frame , pid , data )
326300
@@ -329,7 +303,7 @@ def __init__(self, frame, pid, data):
329303
330304
331305@loggable
332- class SelectionEvent (PlayerActionEvent ):
306+ class SelectionEvent (GameEvent ):
333307 """
334308 Selection events are generated when ever the active selection of the
335309 player is updated. Unlike other game events, these events can also be
@@ -340,10 +314,6 @@ class SelectionEvent(PlayerActionEvent):
340314 by non-player actions. When a player action updates a control group
341315 a :class:`HotkeyEvent` is generated.
342316 """
343-
344- name = 'SelectionEvent'
345- is_player_action = True
346-
347317 def __init__ (self , frame , pid , data ):
348318 super (SelectionEvent , self ).__init__ (frame , pid )
349319
@@ -392,39 +362,32 @@ def __str__(self):
392362def create_control_group_event (frame , pid , data ):
393363 update_type = data ['control_group_update' ]
394364 if update_type == 0 :
395- return SetToHotkeyEvent (frame , pid , data )
365+ return SetControlGroupEvent (frame , pid , data )
396366 elif update_type == 1 :
397- return AddToHotkeyEvent (frame , pid , data )
367+ return AddToControlGroupEvent (frame , pid , data )
398368 elif update_type == 2 :
399- return GetFromHotkeyEvent (frame , pid , data )
369+ return GetControlGroupEvent (frame , pid , data )
400370 elif update_type == 3 :
401371 # TODO: What could this be?!?
402- return HotkeyEvent (frame , pid , data )
372+ return ControlGroupEvent (frame , pid , data )
403373
404374
405375@loggable
406- class HotkeyEvent ( PlayerActionEvent ):
376+ class ControlGroupEvent ( GameEvent ):
407377 """
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
413380 player actions:
414381
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+#)
418385
419386 All three events have the same set of data (shown below) but are interpretted differently.
420387 See the class entry for details.
421388 """
422-
423- name = 'HotkeyEvent'
424- is_player_action = True
425-
426389 def __init__ (self , frame , pid , data ):
427- super (HotkeyEvent , self ).__init__ (frame , pid )
390+ super (ControlGroupEvent , self ).__init__ (frame , pid )
428391
429392 #: Index to the control group being modified
430393 self .control_group = data ['control_group_index' ]
@@ -445,38 +408,33 @@ def __init__(self, frame, pid, data):
445408 self .mask_data = data ['remove_mask' ][1 ]
446409
447410
448- class SetToHotkeyEvent ( HotkeyEvent ):
411+ class SetControlGroupEvent ( ControlGroupEvent ):
449412 """
450- Extends :class:`HotkeyEvent `
413+ Extends :class:`ControlGroupEvent `
451414
452415 This event does a straight forward replace of the current control group contents
453416 with the player's current selection. This event doesn't have masks set.
454417 """
455418
456- name = 'SetToHotkeyEvent'
457419
458-
459- class AddToHotkeyEvent (HotkeyEvent ):
420+ class AddToControlGroupEvent (SetControlGroupEvent ):
460421 """
461- Extends :class:`HotkeyEvent `
422+ Extends :class:`ControlGroupEvent `
462423
463424 This event adds the current selection to the control group.
464425 """
465426
466- name = 'AddToHotkeyEvent'
467-
468427
469- class GetFromHotkeyEvent ( HotkeyEvent ):
428+ class GetControlGroupEvent ( ControlGroupEvent ):
470429 """
471- Extends :class:`HotkeyEvent`
430+ Extends :class:`ControlGroupEvent`
431+
472432 This event replaces the current selection with the contents of the control group.
473433 The mask data is used to limit that selection to units that are currently selectable.
474434 You might have 1 medivac and 8 marines on the control group but if the 8 marines are
475435 inside the medivac they cannot be part of your selection.
476436 """
477437
478- name = 'GetFromHotkeyEvent'
479-
480438
481439@loggable
482440class CameraEvent (GameEvent ):
@@ -485,9 +443,6 @@ class CameraEvent(GameEvent):
485443 It does not matter why the camera changed, this event simply records the current
486444 state of the camera after changing.
487445 """
488-
489- name = 'CameraEvent'
490-
491446 def __init__ (self , frame , pid , data ):
492447 super (CameraEvent , self ).__init__ (frame , pid )
493448
@@ -515,8 +470,10 @@ def __str__(self):
515470
516471@loggable
517472class 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+ """
520477 def __init__ (self , frame , pid , data ):
521478 super (ResourceTradeEvent , self ).__init__ (frame , pid )
522479
@@ -552,8 +509,9 @@ def __str__(self):
552509
553510
554511class ResourceRequestEvent (GameEvent ):
555- name = 'ResourceRequestEvent'
556-
512+ """
513+ Generated when a player creates a resource request.
514+ """
557515 def __init__ (self , frame , pid , data ):
558516 super (ResourceRequestEvent , self ).__init__ (frame , pid )
559517
@@ -577,8 +535,9 @@ def __str__(self):
577535
578536
579537class ResourceRequestFulfillEvent (GameEvent ):
580- name = 'ResourceRequestFulfillEvent'
581-
538+ """
539+ Generated when a player accepts a resource request.
540+ """
582541 def __init__ (self , frame , pid , data ):
583542 super (ResourceRequestFulfillEvent , self ).__init__ (frame , pid )
584543
@@ -587,8 +546,9 @@ def __init__(self, frame, pid, data):
587546
588547
589548class ResourceRequestCancelEvent (GameEvent ):
590- name = 'ResourceRequestCancelEvent'
591-
549+ """
550+ Generated when a player cancels their resource request.
551+ """
592552 def __init__ (self , frame , pid , data ):
593553 super (ResourceRequestCancelEvent , self ).__init__ (frame , pid )
594554
0 commit comments