Skip to content

Commit 8e09a0d

Browse files
committed
APM added for players
1 parent 02f5ca5 commit 8e09a0d

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

sc2reader/objects.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ def __init__(self, pid, data, realm="us"):
179179
self.type = "" # Human or Computer
180180
self.events = list()
181181
self.avg_apm = 0
182-
self.aps = dict()
182+
self.aps = dict() # Doesn't contain seconds with zero actions
183+
self.apm = dict() # Doesn't contain minutes with zero actions
183184

184185
def __str__(self):
185186
return "Player %s - %s (%s)" % (self.pid, self.name, self.actual_race)

sc2reader/replay.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,19 @@ def _parse_events(self):
155155
player = self.player[event.player]
156156
player.events.append(event)
157157

158+
# Calculate APS, APM and average
158159
if event.is_player_action:
159160
if event.seconds in player.aps:
160161
player.aps[event.seconds] += 1
161162
else:
162163
player.aps[event.seconds] = 1
164+
165+
minute = event.seconds/60
166+
if minute in player.apm:
167+
player.apm[minute] += 1
168+
else:
169+
player.apm[minute] = 1
170+
163171
player.avg_apm += 1
164172

165173
# Average the APM

shell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# replay = Replay("1.sc2replay")
77
#
88
# print replay.player["Nexpacisor"].avg_apm
9-
# print replay.player["dblrainbow"].aps
9+
# print replay.player["dblrainbow"].apm

0 commit comments

Comments
 (0)