Skip to content

Commit d3834e7

Browse files
committed
Misc. documentation improvements.
1 parent 554b94d commit d3834e7

File tree

6 files changed

+77
-41
lines changed

6 files changed

+77
-41
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
@@ -18,11 +18,12 @@ class GameEvent(Event):
1818
def __init__(self, frame, pid):
1919
#: The id of the player generating the event. This is 16 for global non-player events.
2020
#: Prior to Heart of the Swarm this was the player id. Since HotS it is
21-
#: now the user id (uid), we still call it pid for backwards compatibility.
21+
#: now the user id (uid), we still call it pid for backwards compatibility. You shouldn't
22+
#: ever need to use this; use :attr:`player` instead.
2223
self.pid = pid
2324

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

2829
#: The frame of the game that this event was recorded at. 16 frames per game second.
@@ -53,6 +54,9 @@ class GameStartEvent(GameEvent):
5354
def __init__(self, frame, pid, data):
5455
super(GameStartEvent, self).__init__(frame, pid)
5556

57+
#: ???
58+
self.data = data
59+
5660

5761
class PlayerLeaveEvent(GameEvent):
5862
"""
@@ -64,6 +68,9 @@ class PlayerLeaveEvent(GameEvent):
6468
def __init__(self, frame, pid, data):
6569
super(PlayerLeaveEvent, self).__init__(frame, pid)
6670

71+
#: ???
72+
self.data = data
73+
6774

6875
class UserOptionsEvent(GameEvent):
6976
"""
@@ -88,7 +95,7 @@ def __init__(self, frame, pid, data):
8895
self.sync_checksumming_enabled = data['sync_checksumming_enabled']
8996

9097
#:
91-
is_map_to_map_transition = data['is_map_to_map_transition']
98+
self.is_map_to_map_transition = data['is_map_to_map_transition']
9299

93100
#:
94101
self.use_ai_beacons = data['use_ai_beacons']
@@ -144,11 +151,31 @@ def __init__(self, frame, pid, data):
144151
#: Flags on the command???
145152
self.flags = data['flags']
146153

147-
#: A dictionary of possible ability flags. Flag names are: alternate,
148-
#: queued, preempt, smart_click, smart_rally, subgroup, set_autocast,
149-
#: set_autocast_on, user, data_a, data_b, data_passenger, data_abil_queue_order_id,
150-
#: ai, ai_ignore_on_finish, is_order, script, homogenous_interruption,
151-
#: minimap, repeat, dispatch_to_other_unit, and target_self
154+
#: A dictionary of possible ability flags. Flags are:
155+
#:
156+
#: * alternate
157+
#: * queued
158+
#: * preempt
159+
#: * smart_click
160+
#: * smart_rally
161+
#: * subgroup
162+
#: * set_autocast,
163+
#: * set_autocast_on
164+
#: * user
165+
#: * data_a
166+
#: * data_b
167+
#: * data_passenger
168+
#: * data_abil_queue_order_id,
169+
#: * ai
170+
#: * ai_ignore_on_finish
171+
#: * is_order
172+
#: * script
173+
#: * homogenous_interruption,
174+
#: * minimap
175+
#: * repeat
176+
#: * dispatch_to_other_unit
177+
#: * target_self
178+
#:
152179
self.flag = dict(
153180
alternate=0x1 & self.flags != 0,
154181
queued=0x2 & self.flags != 0,
@@ -491,13 +518,13 @@ class CameraEvent(GameEvent):
491518
def __init__(self, frame, pid, data):
492519
super(CameraEvent, self).__init__(frame, pid)
493520

494-
#: The x coordinate of the center? of the camera
521+
#: The x coordinate of the center of the camera
495522
self.x = (data['target']['x'] if data['target'] is not None else 0)/256.0
496523

497-
#: The y coordinate of the center? of the camera
524+
#: The y coordinate of the center of the camera
498525
self.y = (data['target']['y'] if data['target'] is not None else 0)/256.0
499526

500-
#: The location of the center? of the camera
527+
#: The location of the center of the camera
501528
self.location = (self.x, self.y)
502529

503530
#: The distance to the camera target ??

sc2reader/events/message.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@ class MessageEvent(Event):
1111
name = 'MessageEvent'
1212

1313
def __init__(self, frame, pid):
14+
#: The user id (or player id for older replays) of the person that generated the event.
1415
self.pid = pid
16+
17+
#: The frame of the game this event was applied
1518
self.frame = frame
19+
20+
#: The second of the game (game time not real time) this event was applied
1621
self.second = frame >> 4
1722

1823
def _str_prefix(self):
@@ -29,10 +34,19 @@ class ChatEvent(MessageEvent):
2934

3035
def __init__(self, frame, pid, target, text):
3136
super(ChatEvent, self).__init__(frame, pid)
37+
#: The numerical target type. 0 = to all; 2 = to allies; 4 = to observers.
3238
self.target = target
39+
40+
#: The text of the message.
3341
self.text = text
42+
43+
#: Flag marked true of message was to all.
3444
self.to_all = (self.target == 0)
45+
46+
#: Flag marked true of message was to allies.
3547
self.to_allies = (self.target == 2)
48+
49+
#: Flag marked true of message was to observers.
3650
self.to_observers = (self.target == 4)
3751

3852

sc2reader/events/tracker.py

Lines changed: 25 additions & 25 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
def load_context(self, replay):
@@ -45,17 +50,15 @@ def __init__(self, frames, data, build):
4550

4651
class PlayerStatsEvent(TrackerEvent):
4752
"""
48-
Player Stats events are generated for all players that were in the game
49-
even if they've since left every 10 seconds. An additional set of stats
50-
events are generated at the end of the game.
53+
Player Stats events are generated for all players that were in the game even if they've since
54+
left every 10 seconds. An additional set of stats events are generated at the end of the game.
5155
52-
When a player leaves the game, a single PlayerStatsEvent is generated
53-
for that player and no one else. That player continues to generate
54-
PlayerStatsEvents at 10 second intervals until the end of the game.
56+
When a player leaves the game, a single PlayerStatsEvent is generated for that player and no
57+
one else. That player continues to generate PlayerStatsEvents at 10 second intervals until the
58+
end of the game.
5559
56-
In 1v1 games, the above behavior can cause the losing player to have 2
57-
events generated at the end of the game. One for leaving and one for
58-
the end of the game.
60+
In 1v1 games, the above behavior can cause the losing player to have 2 events generated at the
61+
end of the game. One for leaving and one for the end of the game.
5962
"""
6063

6164
name = 'PlayerStatsEvent'
@@ -231,15 +234,14 @@ def __str__(self):
231234

232235
class UnitBornEvent(TrackerEvent):
233236
"""
234-
Generated when a unit is created in a finished state in the game. Examples
235-
include the Marine, Zergling, and Zealot (when trained from a gateway).
236-
Units that enter the game unfinished (all buildings, warped in units) generate
237-
a :class:`UnitInitEvent` instead.
238-
239-
Unfortunately, units that are born do not have events marking their beginnings
240-
like :class:`UnitInitEvent` and :class:`UnitDoneEvent` do. The closest thing to
241-
it are the :class:`~sc2reader.event.game.AbilityEvent` game events where the ability
242-
is a train unit command.
237+
Generated when a unit is created in a finished state in the game. Examples include the Marine,
238+
Zergling, and Zealot (when trained from a gateway). Units that enter the game unfinished (all
239+
buildings, warped in units) generate a :class:`UnitInitEvent` instead.
240+
241+
Unfortunately, units that are born do not have events marking their beginnings like
242+
:class:`UnitInitEvent` and :class:`UnitDoneEvent` do. The closest thing to it are the
243+
:class:`~sc2reader.event.game.AbilityEvent` game events where the ability is a train unit
244+
command.
243245
"""
244246

245247
name = 'UnitBornEvent'
@@ -441,10 +443,9 @@ def __str__(self):
441443

442444
class UnitInitEvent(TrackerEvent):
443445
"""
444-
The counter part to :class:`UnitDoneEvent`, generated by the game engine
445-
when a unit is initiated. This applies only to units which are started
446-
in game before they are finished. Primary examples being buildings and
447-
warp-in units.
446+
The counter part to :class:`UnitDoneEvent`, generated by the game engine when a unit is
447+
initiated. This applies only to units which are started in game before they are finished.
448+
Primary examples being buildings and warp-in units.
448449
"""
449450

450451
name = 'UnitInitEvent'
@@ -501,9 +502,8 @@ def __str__(self):
501502

502503
class UnitDoneEvent(TrackerEvent):
503504
"""
504-
The counter part to the :class:`UnitInitEvent`, generated by the game engine
505-
when an initiated unit is completed. E.g. warp-in finished, building finished,
506-
morph complete.
505+
The counter part to the :class:`UnitInitEvent`, generated by the game engine when an initiated
506+
unit is completed. E.g. warp-in finished, building finished, morph complete.
507507
"""
508508

509509
name = 'UnitDoneEvent'

0 commit comments

Comments
 (0)