]> git.xonotic.org Git - xonotic/xonstat.git/blobdiff - xonstat/views/submission.py
Shorten two methods by directly returning the condition.
[xonotic/xonstat.git] / xonstat / views / submission.py
index 14847ad920be2b8bc5c9b985abf0f128bf33881f..322fd5f81afd2814ceec89c353f7ebaa5bdd06bb 100644 (file)
@@ -20,10 +20,7 @@ def is_real_player(events):
     """
     Determines if a given set of events correspond with a non-bot
     """
-    if not events['P'].startswith('bot'):
-        return True
-    else:
-        return False
+    return not events['P'].startswith('bot')
 
 
 def played_in_game(events):
@@ -31,10 +28,7 @@ def played_in_game(events):
     Determines if a given set of player events correspond with a player who
     played in the game (matches 1 and scoreboardvalid 1)
     """
-    if 'matches' in events and 'scoreboardvalid' in events:
-        return True
-    else:
-        return False
+    return 'matches' in events and 'scoreboardvalid' in events
 
 
 class Submission(object):
@@ -109,6 +103,9 @@ class Submission(object):
         # does any human have a non-zero score?
         self.human_nonzero_score = False
 
+        # does any human have a fastest cap?
+        self.human_fastest = False
+
     def next_item(self):
         """Returns the next key:value pair off the queue."""
         try:
@@ -138,6 +135,7 @@ class Submission(object):
 
         player_fired_weapon = False
         player_nonzero_score = False
+        player_fastest = False
 
         # Consume all following 'i' 'n' 't'  'e' records
         while len(self.q) > 0:
@@ -151,8 +149,10 @@ class Submission(object):
                 if sub_key.endswith("cnt-fired"):
                     player_fired_weapon = True
                     self.check_for_new_weapon_fired(sub_key)
-                elif sub_key == 'scoreboard-score' and int(value) != 0:
+                elif sub_key == 'scoreboard-score' and int(sub_value) != 0:
                     player_nonzero_score = True
+                elif sub_key == 'scoreboard-fastest':
+                    player_fastest = True
             elif key == 'n':
                 player[key] = unicode(value, 'utf-8')
             elif key in player_keys:
@@ -174,6 +174,9 @@ class Submission(object):
             if player_nonzero_score:
                 self.human_nonzero_score = True
 
+            if player_fastest:
+                self.human_fastest = True
+
         elif played and not human:
             self.bots.append(player)
         else: