]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Add two static methods used in parsing.
authorAnt Zucaro <azucaro@gmail.com>
Sun, 5 Feb 2017 17:43:28 +0000 (12:43 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Sun, 5 Feb 2017 17:43:28 +0000 (12:43 -0500)
xonstat/views/submission.py

index 967d3b7336a2754a7c59b1117a1144c12ea3e563..8a00bc8a6d60c0d8a72b2dcd56f74e4f0748c159 100644 (file)
@@ -123,6 +123,21 @@ class Submission(object):
         """Adds a weapon to the set of weapons fired during the match (a set)."""
         self.weapons.add(sub_key.split("-")[1])
 
+    @staticmethod
+    def is_human_player(player):
+        """
+        Determines if a given set of events correspond with a non-bot
+        """
+        return not player['P'].startswith('bot')
+
+    @staticmethod
+    def played_in_game(player):
+        """
+        Determines if a given set of player events correspond with a player who
+        played in the game (matches 1 and scoreboardvalid 1)
+        """
+        return 'matches' in player and 'scoreboardvalid' in player
+
     def parse_player(self, key, pid):
         """Construct a player events listing from the submission."""
 
@@ -160,8 +175,8 @@ class Submission(object):
                 self.q.appendleft("{} {}".format(key, value))
                 break
 
-        played = played_in_game(player)
-        human = is_real_player(player)
+        played = self.played_in_game(player)
+        human = self.is_human_player(player)
 
         if played and human:
             self.humans.append(player)