</ul>
<a href="${request.route_url("player_game_index", player_id=player.player_id, page=1)}" title="Game index for ${player.nick}">More games</a> played by ${player.nick_html_colors()}...
% endif
+
+
+% if weapon_stats:
+<h2>Accuracy</h2>
+<table border="1" cellpadding="3">
+<tr>
+ <td></td>
+ <td>Weapon</td>
+ <td>Hit</td>
+ <td>Fired</td>
+ <td>Hit %</td>
+ <td>Actual Damage</td>
+ <td>Potential Damage</td>
+ <td>Damage %</td>
+</tr>
+% for weapon_stat in weapon_stats:
+<%
+if weapon_stat[2] > 0:
+ damage_pct = round(float(weapon_stat[1])/weapon_stat[2]*100, 2)
+else:
+ damage_pct = 0
+if weapon_stat[4] > 0:
+ hit_pct = round(float(weapon_stat[3])/weapon_stat[4]*100, 2)
+else:
+ hit_pct = 0
+%>
+<tr>
+ <td>[IMAGE]</td>
+ <td>${weapon_stat[0]}</td>
+ <td>${weapon_stat[3]}</td>
+ <td>${weapon_stat[4]}</td>
+ <td>${hit_pct}%</td>
+ <td>${weapon_stat[1]}</td>
+ <td>${weapon_stat[2]}</td>
+ <td>${damage_pct}%</td>
+</tr>
+% endfor
+</table>
+
+% endif
player_id = request.matchdict['id']
try:
player = DBSession.query(Player).filter_by(player_id=player_id).one()
+
+ weapon_stats = DBSession.query("descr", "actual_total",
+ "max_total", "hit_total", "fired_total", "frags_total").\
+ from_statement(
+ "select cw.descr, sum(actual) actual_total, "
+ "sum(max) max_total, sum(hit) hit_total, "
+ "sum(fired) fired_total, sum(frags) frags_total "
+ "from xonstat.player_weapon_stats ws, xonstat.cd_weapon cw "
+ "where ws.weapon_cd = cw.weapon_cd "
+ "and player_id = :player_id "
+ "group by descr "
+ "order by descr"
+ ).params(player_id=player_id).all()
+
+ log.debug(weapon_stats)
+
recent_games = DBSession.query(PlayerGameStat, Game, Server, Map).\
filter(PlayerGameStat.player_id == player_id).\
filter(PlayerGameStat.game_id == Game.game_id).\
except Exception as e:
player = None
+ weapon_stats = None
recent_games = None
return {'player':player,
- 'recent_games':recent_games}
+ 'recent_games':recent_games,
+ 'weapon_stats':weapon_stats}
def player_game_index(request):