Skip to content

Commit 1c8e7e3

Browse files
committed
APMTracker needs to track APM for observers as well as players.
1 parent 0f5e949 commit 1c8e7e3

File tree

1 file changed

+8
-8
lines changed
  • sc2reader/engine/plugins

1 file changed

+8
-8
lines changed

sc2reader/engine/plugins/apm.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ class APMTracker(object):
1818
name = 'APMTracker'
1919

2020
def handleInitGame(self, event, replay):
21-
for player in replay.players:
22-
player.apm = defaultdict(int)
23-
player.aps = defaultdict(int)
24-
player.seconds_played = replay.length.seconds
21+
for human in replay.humans:
22+
human.apm = defaultdict(int)
23+
human.aps = defaultdict(int)
24+
human.seconds_played = replay.length.seconds
2525

2626
def handlePlayerActionEvent(self, event, replay):
2727
event.player.aps[event.second] += 1
@@ -31,8 +31,8 @@ def handlePlayerLeaveEvent(self, event, replay):
3131
event.player.seconds_played = event.second
3232

3333
def handleEndGame(self, event, replay):
34-
for player in replay.players:
35-
if len(player.apm.keys()) > 0:
36-
player.avg_apm = sum(player.aps.values())/float(player.seconds_played)*60
34+
for human in replay.humans:
35+
if len(human.apm.keys()) > 0:
36+
human.avg_apm = sum(human.aps.values())/float(human.seconds_played)*60
3737
else:
38-
player.avg_apm = 0
38+
human.avg_apm = 0

0 commit comments

Comments
 (0)