]> git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Fix duel checking.
authorAnt Zucaro <azucaro@gmail.com>
Tue, 27 Dec 2011 22:08:13 +0000 (17:08 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Tue, 27 Dec 2011 22:08:13 +0000 (17:08 -0500)
xonstat/views/submission.py

index 0d2150a81a701c37061bac6f33c956cec62ac004..bbdac59ce4cc0c892a75eca12e9e70127b48145d 100755 (executable)
@@ -70,7 +70,7 @@ def verify_request(request):
     return (idfp, status)\r
 \r
 \r
-def num_real_players(player_events):\r
+def num_real_players(player_events, count_bots=False):\r
     """\r
     Returns the number of real players (those who played \r
     and are on the scoreboard).\r
@@ -78,7 +78,7 @@ def num_real_players(player_events):
     real_players = 0\r
 \r
     for events in player_events:\r
-        if is_real_player(events):\r
+        if is_real_player(events, count_bots):\r
             real_players += 1\r
 \r
     return real_players\r
@@ -124,7 +124,7 @@ def has_required_metadata(metadata):
     return flg_has_req_metadata\r
 \r
 \r
-def is_real_player(events):\r
+def is_real_player(events, count_bots=False):\r
     """\r
     Determines if a given set of player events correspond with a player who\r
 \r
@@ -136,9 +136,10 @@ def is_real_player(events):
     """\r
     flg_is_real = False\r
 \r
-    if not events['P'].startswith('bot'):\r
-        # removing 'joins' here due to bug, but it should be here\r
-        if 'matches' in events and 'scoreboardvalid' in events:\r
+    # removing 'joins' here due to bug, but it should be here\r
+    if 'matches' in events and 'scoreboardvalid' in events:\r
+        if (events['P'].startswith('bot') and count_bots) or \\r
+            not events['P'].startswith('bot'):\r
             flg_is_real = True\r
 \r
     return flg_is_real\r
@@ -568,7 +569,8 @@ def stats_submit(request):
         # FIXME: if we have two players and game type is 'dm',\r
         # change this into a 'duel' gametype. This should be\r
         # removed when the stats actually send 'duel' instead of 'dm'\r
-        if num_real_players(players) == 2 and game_meta['G'] == 'dm':\r
+        if num_real_players(players, count_bots=True) == 2 and \\r
+                game_meta['G'] == 'dm':\r
             game_meta['G'] = 'duel'\r
 \r
         server = get_or_create_server(session=session, hashkey=idfp, \r