Skip to content

Commit 7a7f72e

Browse files
committed
Updates to the project documentation.
1 parent c1fd243 commit 7a7f72e

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

sc2reader/data/__init__.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,26 @@ class Unit(object):
3838
"""
3939

4040
def __init__(self, unit_id, flags):
41-
#: A reference to the player that owns this unit
41+
#: A reference to the player that currently owns this unit. Only available for 2.0.8+ replays.
4242
self.owner = None
4343

44-
#: The frame the unit was started at
44+
#: The frame the unit was started at. Only available for 2.0.8+ replays.
45+
#: Specifically, it is the frame the :class:`~sc2reader.events.tracker.UnitInitEvent` is received. For units
46+
#: that are born and not initiated this will be the same as :attr:`finished_at`.
4547
self.started_at = None
4648

47-
#: The frame the unit was finished at
49+
#: The frame the unit was finished at. Only available for 2.0.8+ replays.
50+
#: Specifically, it is the frame that the :class:`~sc2reader.events.tracker.UnitDoneEvent` is received. For units
51+
#: that are born and not initiated this will be the same as :attr:`started_at`.
4852
self.finished_at = None
4953

50-
#: The frame the unit died at
54+
#: The frame the unit died at. Only available for 2.0.8+ replays.
55+
#: Specifically, it is the frame that the :class:`~sc2reader.events.tracker.UnitDiedEvent` is received.
5156
self.died_at = None
5257

53-
#: A reference to the player that killed this unit. Not always available.
58+
#: A reference to the player that killed this unit. Only available for 2.0.8+ replays.
59+
#: This value is not set if the killer is unknown or not relevant (morphed into a
60+
#: different unit or used to create a building, etc)
5461
self.killed_by = None
5562

5663
#: The unique in-game id for this unit. The id can sometimes be zero because

sc2reader/events/tracker.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class PlayerStatsEvent(TrackerEvent):
3939
events generated at the end of the game. One for leaving and one for
4040
the end of the game.
4141
"""
42+
4243
name = 'PlayerStatsEvent'
4344

4445
def __init__(self, frames, data, build):
@@ -211,6 +212,13 @@ def __str__(self):
211212

212213

213214
class UnitBornEvent(TrackerEvent):
215+
"""
216+
Generated when a unit is created in a finished state in the game. Examples
217+
include the Marine, Zergling, and Zealot (when trained from a gateway).
218+
Units that enter the game unfinished (all buildings, warped in units) generate
219+
a :class:`UnitInitEvent` instead.
220+
"""
221+
214222
name = 'UnitBornEvent'
215223

216224
def __init__(self, frames, data, build):
@@ -257,6 +265,11 @@ def __str__(self):
257265

258266

259267
class UnitDiedEvent(TrackerEvent):
268+
"""
269+
Generated when a unit dies or is removed from the game for any reason. Reasons include
270+
morphing, merging, and getting killed.
271+
"""
272+
260273
name = 'UnitDiedEvent'
261274

262275
def __init__(self, frames, data, build):
@@ -375,6 +388,13 @@ def __str__(self):
375388

376389

377390
class UnitInitEvent(TrackerEvent):
391+
"""
392+
The counter part to :class:`UnitDoneEvent`, generated by the game engine
393+
when a unit is initiated. This applies only to units which are started
394+
in game before they are finished. Primary examples being buildings and
395+
warp-in units.
396+
"""
397+
378398
name = 'UnitInitEvent'
379399

380400
def __init__(self, frames, data, build):
@@ -417,10 +437,16 @@ def __init__(self, frames, data, build):
417437
self.location = (self.x, self.y)
418438

419439
def __str__(self):
420-
return self._str_prefix()+"{0: >15} - Unit inititated {1}".format(self.unit_upkeeper, self.unit)
440+
return self._str_prefix()+"{0: >15} - Unit initiated {1}".format(self.unit_upkeeper, self.unit)
421441

422442

423443
class UnitDoneEvent(TrackerEvent):
444+
"""
445+
The counter part to the :class:`UnitInitEvent`, generated by the game engine
446+
when an initiated unit is completed. E.g. warp-in finished, building finished,
447+
morph complete.
448+
"""
449+
424450
name = 'UnitDoneEvent'
425451

426452
def __init__(self, frames, data, build):

0 commit comments

Comments
 (0)