Skip to content

Commit 90c5c9d

Browse files
committed
Fix the engine's APM plugin and add some documentation.
1 parent a632750 commit 90c5c9d

File tree

1 file changed

+11
-1
lines changed
  • sc2reader/engine/plugins

1 file changed

+11
-1
lines changed

sc2reader/engine/plugins/apm.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
from collections import Counter
22

33
class APMTracker(object):
4+
"""
5+
Builds ``player.aps`` and ``player.apm`` dictionaries where an action is
6+
any Selection, Hotkey, or Ability event.
7+
8+
Also provides ``player.avg_apm`` which is defined as the sum of all the
9+
above actions divided by the number of seconds played by the player (not
10+
necessarily the whole game) multiplied by 60.
11+
12+
APM is 0 for games under 1 minute in length.
13+
"""
414

515
def handleInitGame(self, event, replay):
616
for player in replay.players:
@@ -19,6 +29,6 @@ def handleEndGame(self, event, replay):
1929
print "Handling End Game"
2030
for player in replay.players:
2131
if len(player.apm.keys()) > 0:
22-
player.avg_apm = sum(player.apm.values())/float(player.seconds_played)*60
32+
player.avg_apm = sum(player.aps.values())/float(player.seconds_played)*60
2333
else:
2434
player.avg_apm = 0

0 commit comments

Comments
 (0)