From: Ant Zucaro Date: Sat, 28 Jan 2017 15:01:36 +0000 (-0500) Subject: Check for distinct weapons fired during the match. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2e6546657de9449550c137426e06cb1e1a16706a;p=xonotic%2Fxonstat.git Check for distinct weapons fired during the match. --- diff --git a/xonstat/views/submission.py b/xonstat/views/submission.py index 52d6091..81e639e 100644 --- a/xonstat/views/submission.py +++ b/xonstat/views/submission.py @@ -52,6 +52,13 @@ class Submission(object): except: return None, None + def check_for_new_weapon_fired(self, sub_key): + """Checks if a given player key (subkey, actually) is a new weapon fired in the match.""" + if sub_key.endswith("cnt-fired"): + weapon = sub_key.split("-")[1] + if weapon not in self.weapons: + self.weapons.add(weapon) + def parse_player(self, key, pid): """Construct a player events listing from the submission.""" @@ -68,6 +75,9 @@ class Submission(object): elif key == 'e': (sub_key, sub_value) = value.split(' ', 1) player[sub_key] = sub_value + + # keep track of the distinct weapons fired during the match + self.check_for_new_weapon_fired(sub_key) elif key == 'n': player[key] = unicode(value, 'utf-8') elif key in player_keys: