<%inherit file="base.mako"/>
<%namespace file="scoreboard.mako" import="scoreboard" />
+<%namespace file="accuracy.mako" import="accuracy" />
<%block name="title">
Game Information - ${parent.title()}
% else:
<h2>Game Detail</h2>
<p>
-Played on: ${start_dt.strftime('%m/%d/%Y at %I:%M %p')}<br />
-Game Type: ${game_type_cd}<br />
-Server: <a href="${request.route_url("server_info", id=server_id)}" name="Server info page for ${server_name}">${server_name}</a><br />
-Map: <a href="${request.route_url("map_info", id=map_id)}" name="Map info page for ${map_name}">${map_name}</a><br />
+Played on: ${game.start_dt.strftime('%m/%d/%Y at %I:%M %p')}<br />
+Game Type: ${game.game_type_cd}<br />
+Server: <a href="${request.route_url("server_info", id=server.server_id)}" name="Server info page for ${server.name}">${server.name}</a><br />
+Map: <a href="${request.route_url("map_info", id=map.map_id)}" name="Map info page for ${map.name}">${map.name}</a><br />
</p>
-<h2>Scoreboard</h2>
-<div align="center">
-${scoreboard(game_type_cd, player_game_stats)}
-</div>
+##### SCOREBOARD #####
+<h2>Accuracy</h2>
+${scoreboard(game.game_type_cd, pgstats)}
+<br />
+<br />
+
+
+##### ACCURACY #####
+% for pgstat in pgstats:
+% if pgstat.player_game_stat_id in pwstats:
+Accuracy for ${pgstat.nick_html_colors()}:
+${accuracy(pwstats[pgstat.player_game_stat_id][0:5])}
+<br />
+<br />
+% endif
+% endfor
+
% endif
try:\r
notfound = False\r
\r
- (start_dt, game_type_cd, server_id, server_name, map_id, map_name) = \\r
- DBSession.query("start_dt", "game_type_cd", "server_id", \r
- "server_name", "map_id", "map_name").\\r
- from_statement("select g.start_dt, g.game_type_cd, "\r
- "g.server_id, s.name as server_name, g.map_id, "\r
- "m.name as map_name "\r
- "from games g, servers s, maps m "\r
- "where g.game_id = :game_id "\r
- "and g.server_id = s.server_id "\r
- "and g.map_id = m.map_id").\\r
- params(game_id=game_id).one()\r
+ (game, server, map) = DBSession.query(Game, Server, Map).\\r
+ filter(Game.game_id == game_id).\\r
+ filter(Game.server_id == Server.server_id).\\r
+ filter(Game.map_id == Map.map_id).one()\r
+\r
+ pgstats = DBSession.query(PlayerGameStat).\\r
+ filter(PlayerGameStat.game_id == game_id).\\r
+ order_by(PlayerGameStat.rank).\\r
+ order_by(PlayerGameStat.score).\\r
+ all()\r
+\r
+ pwstats = {}\r
+ for (pwstat, pgstat, weapon) in DBSession.query(PlayerWeaponStat, PlayerGameStat, Weapon).\\r
+ filter(PlayerWeaponStat.game_id == game_id).\\r
+ filter(PlayerWeaponStat.weapon_cd == Weapon.weapon_cd).\\r
+ filter(PlayerWeaponStat.player_game_stat_id == \\r
+ PlayerGameStat.player_game_stat_id).\\r
+ order_by(PlayerGameStat.rank).\\r
+ order_by(PlayerGameStat.score).\\r
+ all():\r
+ if pgstat.player_game_stat_id not in pwstats:\r
+ pwstats[pgstat.player_game_stat_id] = []\r
+\r
+ # NOTE adding pgstat to position 6 in order to display nick.\r
+ # You have to use a slice [0:5] to pass to the accuracy \r
+ # template\r
+ pwstats[pgstat.player_game_stat_id].append((weapon.descr, \r
+ weapon.weapon_cd, pwstat.actual, pwstat.max, \r
+ pwstat.hit, pwstat.fired, pgstat))\r
\r
- player_game_stats = DBSession.query(PlayerGameStat).\\r
- from_statement("select * from player_game_stats "\r
- "where game_id = :game_id "\r
- "order by score desc").\\r
- params(game_id=game_id).all()\r
except Exception as inst:\r
- notfound = True\r
- start_dt = None\r
- game_type_cd = None\r
- server_id = None\r
- server_name = None\r
- map_id = None\r
- map_name = None\r
- player_game_stats = None\r
+ game = None\r
+ server = None\r
+ map = None\r
+ pgstats = None\r
+ pwstats = None\r
+ raise inst\r
\r
- return {'notfound':notfound,\r
- 'start_dt':start_dt,\r
- 'game_type_cd':game_type_cd,\r
- 'server_id':server_id,\r
- 'server_name':server_name,\r
- 'map_id':map_id,\r
- 'map_name':map_name,\r
- 'player_game_stats':player_game_stats}\r
+ return {'game':game,\r
+ 'server':server,\r
+ 'map':map,\r
+ 'pgstats':pgstats,\r
+ 'pwstats':pwstats,\r
+ }\r