File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -90,22 +90,29 @@ def toDict(replay):
90
90
91
91
@plugin
92
92
def APMTracker (replay ):
93
+ """
94
+ Builds ``player.aps`` and ``player.apm`` dictionaries where an action is
95
+ any Selection, Hotkey, or Ability event.
96
+
97
+ Also provides ``player.avg_apm`` which is defined as the sum of all the
98
+ above actions divided by the number of seconds played by the player (not
99
+ necessarily the whole game) multiplied by 60.
100
+ """
93
101
for player in replay .players :
94
102
player .aps = defaultdict (int )
95
103
player .apm = defaultdict (int )
96
- player . seconds_played = replay .length .seconds
104
+ seconds_played = replay .length .seconds
97
105
98
106
for event in player .events :
99
107
if event .name == 'SelectionEvent' or 'AbilityEvent' in event .name or 'Hotkey' in event .name :
100
108
player .aps [event .second ] += 1
101
109
player .apm [event .second / 60 ] += 1
102
110
103
- if event .name == 'PlayerLeaveEvent' :
104
- player .seconds_played = event .second
105
- break
111
+ elif event .name == 'PlayerLeaveEvent' :
112
+ seconds_played = event .second
106
113
107
114
if len (player .apm ) > 0 :
108
- player .avg_apm = sum (player .apm .values ())/ float (player . seconds_played )* 60
115
+ player .avg_apm = sum (player .aps .values ())/ float (seconds_played )* 60
109
116
else :
110
117
player .avg_apm = 0
111
118
You can’t perform that action at this time.
0 commit comments