<%inherit file="base.mako"/>
+<%namespace file="accuracy.mako" import="accuracy" />
<%block name="title">
% if player:
##### ACCURACY #####
% if weapon_stats:
<h2>Accuracy</h2>
-<table class="accuracy-table" border="1" cellpadding="3" align="center">
-<tr class="accuracy-table-header">
- <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[2])/weapon_stat[3]*100, 2)
-else:
- damage_pct = 0
-if weapon_stat[4] > 0:
- hit_pct = round(float(weapon_stat[4])/weapon_stat[5]*100, 2)
-else:
- hit_pct = 0
-%>
-<tr>
- ## Note: the name of the image must match up with the weapon_cd
- ## entry of that weapon, else this won't work
- <td><img src="${request.static_url("xonstat:static/images/%s.png" % weapon_stat[1])}" /></td>
- <td style="text-align: left;">${weapon_stat[0]}</td>
- <td>${weapon_stat[4]}</td>
- <td>${weapon_stat[5]}</td>
- <td>${hit_pct}%</td>
- <td>${weapon_stat[2]}</td>
- <td>${weapon_stat[3]}</td>
- <td>${damage_pct}%</td>
-</tr>
-% endfor
-</table>
-
+${accuracy(weapon_stats)}
% endif
+
##### RECENT GAMES #####
% if recent_games:
<h2>Recent Games</h2>
<%inherit file="base.mako"/>
+<%namespace file="accuracy.mako" import="accuracy" />
<%block name="title">
Accuracy Information - ${parent.title()}
</%block>
-% if pwstats is None or pgstat is None or game is None:
+% if weapon_stats 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 for <a href="${request.route_url("player_info", id=pgstat.player_id)}" title="Info page for this player">${pgstat.nick_html_colors()}</a> in Game <a href="" title="">${game.game_id}</a>:</h2>
-<table border="1" cellpadding="3">
- <tr>
- <td>Weapon</td>
- <td>Fired</td>
- <td>Hit</td>
- <td>Hit %</td>
- <td>Potential Damage</td>
- <td>Actual Damage</td>
- <td>Damage %</td>
- <td>Frags</td>
- </tr>
-% for (pwstat, weapon) in pwstats:
- <tr>
- <td>${weapon.descr}</td>
- <td>${pwstat.fired}</td>
- <td>${pwstat.hit}</td>
- <td>${round(float(pwstat.hit)/pwstat.fired*100, 2)}%</td>
- <td>${pwstat.max}</td>
- <td>${pwstat.actual}</td>
- <td>${round(float(pwstat.actual)/pwstat.max*100, 2)}%</td>
- <td>${pwstat.frags}</td>
- </tr>
-% endfor
-</table>
+## ACCURACY TABLE
+% if weapon_stats:
+${accuracy(weapon_stats)}
+% endif
+
% endif
"""\r
players = DBSession.query(Player)\r
\r
- log.debug("testing logging; entered PlayerHandler.index()")\r
return {'players':players}\r
\r
def player_info(request):\r
"order by descr"\r
).params(player_id=player_id).all()\r
\r
- log.debug(weapon_stats)\r
-\r
recent_games = DBSession.query(PlayerGameStat, Game, Server, Map).\\r
filter(PlayerGameStat.player_id == player_id).\\r
filter(PlayerGameStat.game_id == Game.game_id).\\r
except Exception as e:\r
player = None\r
games = None\r
- raise e\r
\r
return {'player':player,\r
'games':games}\r
order_by(Weapon.descr).\\r
all()\r
\r
+ # turn this into something the accuracy template can use\r
+ weapon_stats = []\r
+ for (pwstat, weapon) in pwstats:\r
+ weapon_stats.append((weapon.descr, pwstat.weapon_cd, pwstat.fired,\r
+ pwstat.hit, pwstat.max, pwstat.actual))\r
+\r
pgstat = DBSession.query(PlayerGameStat).\\r
filter_by(player_game_stat_id=pgstat_id).one()\r
\r
game = DBSession.query(Game).filter_by(game_id=game_id).one()\r
\r
- log.debug(pwstats)\r
- log.debug(pgstat)\r
- log.debug(game)\r
-\r
except Exception as e:\r
- pwstats = None\r
+ weapon_stats = None\r
pgstat = None\r
game = None\r
- raise e\r
- return {'pwstats':pwstats, 'pgstat':pgstat, 'game':game}\r
+ return {'weapon_stats':weapon_stats, 'pgstat':pgstat, 'game':game}\r