</%block>
-% if pwstats is None:
+% if pwstats is None or pgstat is None or game is None:
<h2>Sorry, I can't find those weapon stats!</h2>
<p>Assume the best, though. Really.</p>
% else:
-<h2>Player Accuracy:</h2>
+<h2>Player Accuracy for ${pgstat.nick_html_colors()} in Game:</h2>
<table border="1" cellpadding="3">
<tr>
<td>Weapon</td>
order_by(Weapon.descr).\
all()
+ pgstat = DBSession.query(PlayerGameStat).\
+ filter_by(player_game_stat_id=pgstat_id).one()
+
+ game = DBSession.query(Game).filter_by(game_id=game_id).one()
+
+ log.debug(pwstats)
+ log.debug(pgstat)
+ log.debug(game)
+
except Exception as e:
pwstats = None
- return {'pwstats':pwstats}
+ pgstat = None
+ game = None
+ raise e
+ return {'pwstats':pwstats, 'pgstat':pgstat, 'game':game}
##########################################################################
return game
# search for a player and if found, create a new one (w/ hashkey)
-def get_or_create_player(session=None, hashkey=None):
+def get_or_create_player(session=None, hashkey=None, nick=None):
# if we have a bot
if re.search('^bot#\d+$', hashkey):
player = session.query(Player).filter_by(player_id=1).one()
player.player_id, hashkey.hashkey))
except:
player = Player()
+
+ if nick:
+ player.nick = nick
+
session.add(player)
session.flush()
hashkey = Hashkey(player_id=player.player_id, hashkey=hashkey)
# and add stats for each if they were present at the end
# of the game
for player_events in players:
+ if 'n' in player_events:
+ nick = player_events['n']
+ else:
+ nick = None
+
player = get_or_create_player(session=session,
- hashkey=player_events['P'])
+ hashkey=player_events['P'], nick=nick)
log.debug('Creating stats for %s' % player_events['P'])
create_player_stats(session=session, player=player, game=game,
player_events=player_events)