return flg_has_req_metadata\r
\r
\r
+def should_do_weapon_stats(game_type_cd):\r
+ """True of the game type should record weapon stats. False otherwise."""\r
+ if game_type_cd in 'cts':\r
+ return False\r
+ else:\r
+ return True\r
+\r
+\r
+def should_do_elos(game_type_cd):\r
+ """True of the game type should process Elos. False otherwise."""\r
+ elo_game_types = ('duel', 'dm', 'ctf', 'tdm', 'kh',\r
+ 'ka', 'ft', 'freezetag')\r
+\r
+ if game_type_cd in elo_game_types:\r
+ return True\r
+ else:\r
+ return False\r
+\r
+\r
def register_new_nick(session, player, new_nick):\r
"""\r
Change the player record's nick to the newly found nick. Store the old\r
\r
def create_weapon_stats(session, game_meta, game, player, pgstat, events):\r
"""Weapon stats handler for all game types"""\r
- if game.game_type_cd in 'cts' or player.player_id == 1:\r
- return []\r
-\r
pwstats = []\r
\r
# Version 1 of stats submissions doubled the data sent.\r
\r
def create_elos(session, game):\r
"""Elo handler for all game types."""\r
-\r
- # the following game types do not record elo\r
- if game.game_type_cd in 'cts':\r
- return None\r
-\r
try:\r
process_elos(game, session)\r
except Exception as e:\r
do_precondition_checks(request, game_meta, raw_players)\r
\r
# the "duel" gametype is fake\r
- if num_real_players(raw_players) == 2 and game_meta['G'] == 'dm':\r
+ if len(raw_players) == 2 \\r
+ and num_real_players(raw_players) == 2 \\r
+ and game_meta['G'] == 'dm':\r
game_meta['G'] = 'duel'\r
\r
#----------------------------------------------------------------------\r
pgstat = create_game_stat(session, game_meta, game, server,\r
gmap, player, events)\r
\r
- pwstats = create_weapon_stats(session, game_meta, game, player,\r
- pgstat, events)\r
+ if should_do_weapon_stats(game_type_cd) and player.player_id > 1:\r
+ pwstats = create_weapon_stats(session, game_meta, game, player,\r
+ pgstat, events)\r
\r
- create_elos(session, game)\r
+ if should_do_elos(game_type_cd):\r
+ create_elos(session, game)\r
\r
session.commit()\r
log.debug('Success! Stats recorded.')\r