From b14696ba10e9abaa301a7f7700273f3ca6c4430a Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Thu, 8 Nov 2012 23:42:29 -0500 Subject: [PATCH] Handle Elos properly when players have big alivetimes. Due to a bug, the alivetimes for players also include time spent in warmup. Since elo uses score per second, the skewed alivetime made players who actually lost look like they won under certain circumstances (like when their opponent spent a very long time in warmup). This change puts a ceiling on the alivetime used by Elo by limiting the alivetime to be at most the game's duration. --- xonstat/elo.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xonstat/elo.py b/xonstat/elo.py index 48a24e8..74c49cd 100644 --- a/xonstat/elo.py +++ b/xonstat/elo.py @@ -63,7 +63,15 @@ def process_elos(game, session, game_type_cd=None): filter(PlayerGameStat.player_id > 2).\ all(): # scores are per second - scores[p] = s/float(a.seconds) + # with a short circuit to handle alivetimes > game + # durations, which can happen due to warmup being + # included (most often in duels) + if game.duration is not None: + if a.seconds > game.duration.seconds: + scores[p] = s/float(game.duration.seconds) + else: + scores[p] = s/float(a.seconds) + alivetimes[p] = a.seconds player_ids = scores.keys() -- 2.39.2