Skip to content

Commit bb8f9d2

Browse files
committed
Misc. documentation improvements.
1 parent 24c0acf commit bb8f9d2

File tree

6 files changed

+92
-48
lines changed

6 files changed

+92
-48
lines changed

docs/source/events/game.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ computer player.
1111

1212
.. automodule:: sc2reader.events.game
1313
:members:
14-
:undoc-members:

docs/source/events/message.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,5 @@
33
Message Events
44
===================
55

6-
Coming soon!
7-
86
.. automodule:: sc2reader.events.message
97
:members:
10-
:undoc-members:

docs/source/events/tracker.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ are also periodically recorded to snapshot aspects of the current game state.
99

1010
.. automodule:: sc2reader.events.tracker
1111
:members:
12-
:undoc-members:

sc2reader/events/game.py

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ class GameEvent(Event):
1616
def __init__(self, frame, pid):
1717
#: The id of the player generating the event. This is 16 for global non-player events.
1818
#: Prior to Heart of the Swarm this was the player id. Since HotS it is
19-
#: now the user id (uid), we still call it pid for backwards compatibility.
19+
#: now the user id (uid), we still call it pid for backwards compatibility. You shouldn't
20+
#: ever need to use this; use :attr:`player` instead.
2021
self.pid = pid
2122

2223
#: A reference to the :class:`~sc2reader.objects.Player` object representing
23-
#: this player in the replay. Not available for global events (:attr:`pid` = 16)
24+
#: this player in the replay. Not available for global events (:attr:`is_local` = False)
2425
self.player = None
2526

2627
#: The frame of the game that this event was recorded at. 16 frames per game second.
@@ -51,6 +52,9 @@ class GameStartEvent(GameEvent):
5152
def __init__(self, frame, pid, data):
5253
super(GameStartEvent, self).__init__(frame, pid)
5354

55+
#: ???
56+
self.data = data
57+
5458

5559
class PlayerLeaveEvent(GameEvent):
5660
"""
@@ -59,6 +63,9 @@ class PlayerLeaveEvent(GameEvent):
5963
def __init__(self, frame, pid, data):
6064
super(PlayerLeaveEvent, self).__init__(frame, pid)
6165

66+
#: ???
67+
self.data = data
68+
6269

6370
class UserOptionsEvent(GameEvent):
6471
"""
@@ -80,7 +87,7 @@ def __init__(self, frame, pid, data):
8087
self.sync_checksumming_enabled = data['sync_checksumming_enabled']
8188

8289
#:
83-
is_map_to_map_transition = data['is_map_to_map_transition']
90+
self.is_map_to_map_transition = data['is_map_to_map_transition']
8491

8592
#:
8693
self.use_ai_beacons = data['use_ai_beacons']
@@ -127,11 +134,31 @@ def __init__(self, frame, pid, data):
127134
#: Flags on the command???
128135
self.flags = data['flags']
129136

130-
#: A dictionary of possible ability flags. Flag names are: alternate,
131-
#: queued, preempt, smart_click, smart_rally, subgroup, set_autocast,
132-
#: set_autocast_on, user, data_a, data_b, data_passenger, data_abil_queue_order_id,
133-
#: ai, ai_ignore_on_finish, is_order, script, homogenous_interruption,
134-
#: minimap, repeat, dispatch_to_other_unit, and target_self
137+
#: A dictionary of possible ability flags. Flags are:
138+
#:
139+
#: * alternate
140+
#: * queued
141+
#: * preempt
142+
#: * smart_click
143+
#: * smart_rally
144+
#: * subgroup
145+
#: * set_autocast,
146+
#: * set_autocast_on
147+
#: * user
148+
#: * data_a
149+
#: * data_b
150+
#: * data_passenger
151+
#: * data_abil_queue_order_id,
152+
#: * ai
153+
#: * ai_ignore_on_finish
154+
#: * is_order
155+
#: * script
156+
#: * homogenous_interruption,
157+
#: * minimap
158+
#: * repeat
159+
#: * dispatch_to_other_unit
160+
#: * target_self
161+
#:
135162
self.flag = dict(
136163
alternate=0x1 & self.flags != 0,
137164
queued=0x2 & self.flags != 0,
@@ -446,13 +473,13 @@ class CameraEvent(GameEvent):
446473
def __init__(self, frame, pid, data):
447474
super(CameraEvent, self).__init__(frame, pid)
448475

449-
#: The x coordinate of the center? of the camera
476+
#: The x coordinate of the center of the camera
450477
self.x = (data['target']['x'] if data['target'] is not None else 0)/256.0
451478

452-
#: The y coordinate of the center? of the camera
479+
#: The y coordinate of the center of the camera
453480
self.y = (data['target']['y'] if data['target'] is not None else 0)/256.0
454481

455-
#: The location of the center? of the camera
482+
#: The location of the center of the camera
456483
self.location = (self.x, self.y)
457484

458485
#: The distance to the camera target ??

sc2reader/events/message.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ class MessageEvent(Event):
1212
Parent class for all message events.
1313
"""
1414
def __init__(self, frame, pid):
15+
#: The user id (or player id for older replays) of the person that generated the event.
1516
self.pid = pid
17+
18+
#: The frame of the game this event was applied
1619
self.frame = frame
20+
21+
#: The second of the game (game time not real time) this event was applied
1722
self.second = frame >> 4
1823

1924
#: Short cut string for event class name
@@ -34,10 +39,19 @@ class ChatEvent(MessageEvent):
3439
"""
3540
def __init__(self, frame, pid, target, text):
3641
super(ChatEvent, self).__init__(frame, pid)
42+
#: The numerical target type. 0 = to all; 2 = to allies; 4 = to observers.
3743
self.target = target
44+
45+
#: The text of the message.
3846
self.text = text
47+
48+
#: Flag marked true of message was to all.
3949
self.to_all = (self.target == 0)
50+
51+
#: Flag marked true of message was to allies.
4052
self.to_allies = (self.target == 2)
53+
54+
#: Flag marked true of message was to observers.
4155
self.to_observers = (self.target == 4)
4256

4357

sc2reader/events/tracker.py

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@
1010

1111

1212
class TrackerEvent(Event):
13+
"""
14+
Parent class for all tracker events.
15+
"""
1316
def __init__(self, frames):
1417
#: The frame of the game this event was applied
1518
self.frame = frames
19+
20+
#: The second of the game (game time not real time) this event was applied
1621
self.second = frames >> 4
1722

1823
#: Short cut string for event class name
@@ -30,17 +35,15 @@ def __str__(self):
3035

3136
class PlayerStatsEvent(TrackerEvent):
3237
"""
33-
Player Stats events are generated for all players that were in the game
34-
even if they've since left every 10 seconds. An additional set of stats
35-
events are generated at the end of the game.
38+
Player Stats events are generated for all players that were in the game even if they've since
39+
left every 10 seconds. An additional set of stats events are generated at the end of the game.
3640
37-
When a player leaves the game, a single PlayerStatsEvent is generated
38-
for that player and no one else. That player continues to generate
39-
PlayerStatsEvents at 10 second intervals until the end of the game.
41+
When a player leaves the game, a single PlayerStatsEvent is generated for that player and no
42+
one else. That player continues to generate PlayerStatsEvents at 10 second intervals until the
43+
end of the game.
4044
41-
In 1v1 games, the above behavior can cause the losing player to have 2
42-
events generated at the end of the game. One for leaving and one for
43-
the end of the game.
45+
In 1v1 games, the above behavior can cause the losing player to have 2 events generated at the
46+
end of the game. One for leaving and one for the end of the game.
4447
"""
4548
def __init__(self, frames, data, build):
4649
super(PlayerStatsEvent, self).__init__(frames)
@@ -213,15 +216,14 @@ def __str__(self):
213216

214217
class UnitBornEvent(TrackerEvent):
215218
"""
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-
Unfortunately, units that are born do not have events marking their beginnings
222-
like :class:`UnitInitEvent` and :class:`UnitDoneEvent` do. The closest thing to
223-
it are the :class:`~sc2reader.event.game.AbilityEvent` game events where the ability
224-
is a train unit command.
219+
Generated when a unit is created in a finished state in the game. Examples include the Marine,
220+
Zergling, and Zealot (when trained from a gateway). Units that enter the game unfinished (all
221+
buildings, warped in units) generate a :class:`UnitInitEvent` instead.
222+
223+
Unfortunately, units that are born do not have events marking their beginnings like
224+
:class:`UnitInitEvent` and :class:`UnitDoneEvent` do. The closest thing to it are the
225+
:class:`~sc2reader.event.game.AbilityEvent` game events where the ability is a train unit
226+
command.
225227
"""
226228
def __init__(self, frames, data, build):
227229
super(UnitBornEvent, self).__init__(frames)
@@ -253,10 +255,12 @@ def __init__(self, frames, data, build):
253255
#: The player object that controls this unit. 0 means neutral unit
254256
self.unit_controller = None
255257

256-
#: The x coordinate of the location
258+
#: The x coordinate of the location with 4 point resolution. E.g. 13.75 recorded as 12.
259+
#: Location prior to rounding marks the center of the unit footprint.
257260
self.x = data[5] * 4
258261

259-
#: The y coordinate of the location
262+
#: The y coordinate of the location with 4 point resolution. E.g. 13.75 recorded as 12.
263+
#: Location prior to rounding marks the center of the unit footprint.
260264
self.y = data[6] * 4
261265

262266
#: The map location of the unit birth
@@ -292,10 +296,12 @@ def __init__(self, frames, data, build):
292296
#: The player object of the that killed the unit. Not always available.
293297
self.killer = None
294298

295-
#: The x coordinate of the location
299+
#: The x coordinate of the location with 4 point resolution. E.g. 13.75 recorded as 12.
300+
#: Location prior to rounding marks the center of the unit footprint.
296301
self.x = data[3] * 4
297302

298-
#: The y coordinate of the location
303+
#: The y coordinate of the location with 4 point resolution. E.g. 13.75 recorded as 12.
304+
#: Location prior to rounding marks the center of the unit footprint.
299305
self.y = data[4] * 4
300306

301307
#: The map location the unit was killed at.
@@ -394,10 +400,9 @@ def __str__(self):
394400

395401
class UnitInitEvent(TrackerEvent):
396402
"""
397-
The counter part to :class:`UnitDoneEvent`, generated by the game engine
398-
when a unit is initiated. This applies only to units which are started
399-
in game before they are finished. Primary examples being buildings and
400-
warp-in units.
403+
The counter part to :class:`UnitDoneEvent`, generated by the game engine when a unit is
404+
initiated. This applies only to units which are started in game before they are finished.
405+
Primary examples being buildings and warp-in units.
401406
"""
402407
def __init__(self, frames, data, build):
403408
super(UnitInitEvent, self).__init__(frames)
@@ -429,10 +434,12 @@ def __init__(self, frames, data, build):
429434
#: The player object that controls this unit. 0 means neutral unit
430435
self.unit_controller = None
431436

432-
#: The x coordinate of the location
437+
#: The x coordinate of the location with 4 point resolution. E.g. 13.75 recorded as 12.
438+
#: Location prior to rounding marks the center of the unit footprint.
433439
self.x = data[5] * 4
434440

435-
#: The y coordinate of the location
441+
#: The y coordinate of the location with 4 point resolution. E.g. 13.75 recorded as 12.
442+
#: Location prior to rounding marks the center of the unit footprint.
436443
self.y = data[6] * 4
437444

438445
#: The map location the unit was started at
@@ -444,9 +451,8 @@ def __str__(self):
444451

445452
class UnitDoneEvent(TrackerEvent):
446453
"""
447-
The counter part to the :class:`UnitInitEvent`, generated by the game engine
448-
when an initiated unit is completed. E.g. warp-in finished, building finished,
449-
morph complete.
454+
The counter part to the :class:`UnitInitEvent`, generated by the game engine when an initiated
455+
unit is completed. E.g. warp-in finished, building finished, morph complete.
450456
"""
451457
def __init__(self, frames, data, build):
452458
super(UnitDoneEvent, self).__init__(frames)
@@ -485,7 +491,9 @@ def __init__(self, frames, data, build):
485491
#: A dict mapping of units that had their position updated to their positions
486492
self.units = dict()
487493

488-
#: A list of (unit_index, (x,y)) derived from the first_unit_index and items
494+
#: A list of (unit_index, (x,y)) derived from the first_unit_index and items. Like the other
495+
#: tracker events, these coordinates have 4 point resolution. (15,25) recorded as (12,24).
496+
#: Location prior to rounding marks the center of the unit footprint.
489497
self.positions = list()
490498

491499
unit_index = self.first_unit_index

0 commit comments

Comments
 (0)