-
Notifications
You must be signed in to change notification settings - Fork 147
Fix LotV apm #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix LotV apm #12
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,21 +100,30 @@ def APMTracker(replay): | |
| above actions divided by the number of seconds played by the player (not | ||
| necessarily the whole game) multiplied by 60. | ||
| """ | ||
|
|
||
| speed_multiplier = 1 | ||
| if replay.expansion == 'LotV': | ||
| speed_multiplier = 1.4 | ||
|
|
||
| game_seconds_per_second = 1.4 | ||
| if replay.expansion == 'LotV': | ||
| game_seconds_per_second = 1.4 | ||
|
||
|
|
||
| for player in replay.players: | ||
| player.aps = defaultdict(int) | ||
| player.apm = defaultdict(int) | ||
| player.seconds_played = replay.length.seconds | ||
|
|
||
| for event in player.events: | ||
| if event.name == 'SelectionEvent' or 'AbilityEvent' in event.name or 'Hotkey' in event.name: | ||
| player.aps[event.second] += 1.4 | ||
| player.apm[int(event.second/60)] += 1.4 | ||
| player.aps[event.second/speed_multiplier] += game_seconds_per_second | ||
| player.apm[int(event.second/60/speed_multiplier)] += game_seconds_per_second | ||
|
|
||
| elif event.name == 'PlayerLeaveEvent': | ||
| player.seconds_played = event.second | ||
| player.seconds_played = event.second/speed_multiplier | ||
|
|
||
| if len(player.apm) > 0: | ||
| player.avg_apm = sum(player.aps.values())/float(player.seconds_played)*60 | ||
| player.avg_apm = sum(player.aps.values())/float(player.seconds_played)*60*speed_multiplier | ||
| else: | ||
| player.avg_apm = 0 | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about consolidating all the
1.4s into a single place? i see them insc2reader/engine/plugins/apm.py,sc2reader/factories/plugins/replay.pyandsc2reader/resources.py