Skip to content

Commit b4f1eaa

Browse files
committed
Changes to the AbilityEvent interface.
Changes: * Event.ability => Event.ability_code * Event.ability_name now represents the ability name. NOTE: In the future Event.ability will point to the ability object.
1 parent f04dbdc commit b4f1eaa

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

sc2reader/events.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,13 @@ def load_context(self, replay):
119119
class AbilityEvent(PlayerActionEvent):
120120
def __init__(self, framestamp, player, type, code, ability):
121121
super(AbilityEvent, self).__init__(framestamp, player, type, code)
122-
self.ability = ability
122+
self.ability_code = ability
123+
self.ability_name = 'Uknown'
123124

124125
def load_context(self, replay):
125126
super(AbilityEvent, self).load_context(replay)
126127

127-
if self.ability not in replay.datapack.abilities:
128+
if self.ability_code not in replay.datapack.abilities:
128129
if not getattr(replay, 'marked_error', None):
129130
replay.marked_error=True
130131
self.logger.error(replay.filename)
@@ -133,6 +134,10 @@ def load_context(self, replay):
133134
self.logger.error("\t"+str(player))
134135
self.logger.error("{0}\t{1}\tMissing ability {2} from {3}".format(self.frame, self.player.name, hex(self.ability), replay.datapack.__class__.__name__))
135136

137+
else:
138+
self.ability_name = replay.datapack.abilities[self.ability_code]
139+
140+
136141
def __str__(self):
137142
if not self.ability:
138143
return self._str_prefix() + "Move"

0 commit comments

Comments
 (0)