Skip to content

Commit a515bfa

Browse files
committed
Process ability flags into a more accessible boolean lookup.
1 parent 3e314e8 commit a515bfa

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

sc2reader/events/game.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,42 @@ class AbilityEvent(GameEvent):
7676
def __init__(self, frame, pid, data):
7777
super(AbilityEvent, self).__init__(frame, pid)
7878

79+
7980
#: Flags on the command???
8081
self.flags = data['flags']
8182

83+
84+
#: A dictionary of possible ability flags. Flag names are: alternate,
85+
#: queued, preempt, smart_click, smart_rally, subgroup, set_autocast,
86+
#: set_autocast_on, user, data_a, data_b, data_passenger, data_abil_queue_order_id,
87+
#: ai, ai_ignore_on_finish, is_order, script, homogenous_interruption,
88+
#: minimap, repeat, dispatch_to_other_unit, and target_self
89+
self.flag = dict(
90+
alternate=0x1 & self.flags != 0,
91+
queued=0x2 & self.flags != 0,
92+
preempt=0x4 & self.flags != 0,
93+
smart_click=0x8 & self.flags != 0,
94+
smart_rally=0x10 & self.flags != 0,
95+
subgroup=0x20 & self.flags != 0,
96+
set_autocast=0x40 & self.flags != 0,
97+
set_autocast_on=0x80 & self.flags != 0,
98+
user=0x100 & self.flags != 0,
99+
data_a=0x200 & self.flags != 0,
100+
data_passenger=0x200 & self.flags != 0, # alt-name
101+
data_b=0x400 & self.flags != 0,
102+
data_abil_queue_order_id=0x400 & self.flags != 0, # alt-name
103+
ai=0x800 & self.flags != 0,
104+
ai_ignore_on_finish=0x1000 & self.flags != 0,
105+
is_order=0x2000 & self.flags != 0,
106+
script=0x4000 & self.flags != 0,
107+
homogenous_interruption=0x8000 & self.flags != 0,
108+
minimap=0x10000 & self.flags != 0,
109+
repeat=0x20000 & self.flags != 0,
110+
dispatch_to_other_unit=0x40000 & self.flags != 0,
111+
target_self=0x80000 & self.flags != 0,
112+
)
113+
114+
82115
#: Flag marking that the command had ability information
83116
self.has_ability = data['ability'] != None
84117

sc2reader/readers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ def command_event(self, data):
738738

739739
# Still, return something with a consistent structure
740740
return dict(
741-
flags = None,
741+
flags = 0,
742742
ability = None,
743743
data = ('None',None),
744744
other_unit_tag = None,

0 commit comments

Comments
 (0)