From: Ant Zucaro Date: Thu, 26 May 2011 14:10:08 +0000 (-0400) Subject: Spruce up the player info page a bit: add weapon images for accuracy for starters. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b52cd596117bd2e52434d99b913e7155638e054f;p=xonotic%2Fxonstat.git Spruce up the player info page a bit: add weapon images for accuracy for starters. --- diff --git a/xonstat/static/css/style.css b/xonstat/static/css/style.css index d7c01c1..c4f5ae1 100755 --- a/xonstat/static/css/style.css +++ b/xonstat/static/css/style.css @@ -25,6 +25,14 @@ body { font-weight: bold; } +.accuracy-table{ + text-align: center; +} + +.accuracy-table-header{ + background-color: #E8E8E8; +} + .nick { font-family: 'Xolonium', 'Arial', 'Helvetica'; font-size: 14px; diff --git a/xonstat/templates/player_info.mako b/xonstat/templates/player_info.mako index 9c9885f..70c0197 100755 --- a/xonstat/templates/player_info.mako +++ b/xonstat/templates/player_info.mako @@ -20,20 +20,12 @@ ${parent.title()}

% endif -% if recent_games: -

Recent Games

-% for (gamestat, game, server, map) in recent_games: - #${game.game_id}: ${map.name} on ${server.name} -
-% endfor -More games played by ${player.nick_html_colors()}... -% endif - +##### ACCURACY ##### % if weapon_stats:

Accuracy

- - +
+ @@ -46,25 +38,39 @@ ${parent.title()} % for weapon_stat in weapon_stats: <% if weapon_stat[2] > 0: - damage_pct = round(float(weapon_stat[1])/weapon_stat[2]*100, 2) + 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[3])/weapon_stat[4]*100, 2) + hit_pct = round(float(weapon_stat[4])/weapon_stat[5]*100, 2) else: hit_pct = 0 %> - - - + ## Note: the name of the image must match up with the weapon_cd + ## entry of that weapon, else this won't work + + + - + % endfor
Weapon Hit
[IMAGE]${weapon_stat[0]}${weapon_stat[3]}${weapon_stat[0]} ${weapon_stat[4]}${weapon_stat[5]} ${hit_pct}%${weapon_stat[1]} ${weapon_stat[2]}${weapon_stat[3]} ${damage_pct}%
% endif + +##### RECENT GAMES ##### +% if recent_games: +

Recent Games

+% for (gamestat, game, server, map) in recent_games: + #${game.game_id}: ${map.name} on ${server.name} +
+% endfor +More games played by ${player.nick_html_colors()}... +% endif + + diff --git a/xonstat/views/player.py b/xonstat/views/player.py index 9337b83..8db3c55 100755 --- a/xonstat/views/player.py +++ b/xonstat/views/player.py @@ -28,16 +28,16 @@ def player_info(request): try: player = DBSession.query(Player).filter_by(player_id=player_id).one() - weapon_stats = DBSession.query("descr", "actual_total", + weapon_stats = DBSession.query("descr", "weapon_cd", "actual_total", "max_total", "hit_total", "fired_total", "frags_total").\ from_statement( - "select cw.descr, sum(actual) actual_total, " + "select cw.descr, cw.weapon_cd, 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 " + "group by descr, cw.weapon_cd " "order by descr" ).params(player_id=player_id).all()