Skip to content

Commit c0eeb2a

Browse files
committed
Make links between players and killed units.
1 parent 2d5b045 commit c0eeb2a

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

sc2reader/data/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def __init__(self, unit_id, flags):
3838
#: The frame the unit died at
3939
self.died_at = None
4040

41+
#: A reference to the player that killed this unit. Not always available.
42+
self.killed_by = None
43+
4144
self.id = unit_id
4245
self.flags = flags
4346
self._type_class = None

sc2reader/events/tracker.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ def load_context(self, replay):
256256

257257
if self.killer_pid in replay.player:
258258
self.killer = replay.player[self.killer_pid]
259+
if self.unit:
260+
self.unit.killed_by = self.killer
261+
self.killer.killed_units.append(self.unit)
259262
elif self.killer_pid:
260263
pass#print "Unknown killer pid", self.killer_pid
261264

sc2reader/objects.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ def __init__(self, pid, name):
204204
#: A list of references to the units the player had this game
205205
self.units = list()
206206

207+
#: A list of references to the units that the player killed this game
208+
self.killed_units = list()
209+
207210

208211
@property
209212
def url(self):

0 commit comments

Comments
 (0)