]> git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Spruce up the player info page a bit: add weapon images for accuracy for starters.
authorAnt Zucaro <azucaro@gmail.com>
Thu, 26 May 2011 14:10:08 +0000 (10:10 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Thu, 26 May 2011 14:10:08 +0000 (10:10 -0400)
xonstat/static/css/style.css
xonstat/templates/player_info.mako
xonstat/views/player.py

index d7c01c10977e2e8af9e4cf71e0126e3ef6d0c101..c4f5ae11d27064d34190797e56cfc3bc192b7964 100755 (executable)
@@ -25,6 +25,14 @@ body {
     font-weight: bold;\r
 }\r
 \r
+.accuracy-table{\r
+    text-align: center;\r
+}\r
+\r
+.accuracy-table-header{\r
+    background-color: #E8E8E8;\r
+}\r
+\r
 .nick {\r
     font-family: 'Xolonium', 'Arial', 'Helvetica';\r
     font-size: 14px;\r
index 9c9885f4d956894f3b5ab1a55134220f87af4ae6..70c01973661c9969cd21a2a18b13342c2ded3f1a 100755 (executable)
@@ -20,20 +20,12 @@ ${parent.title()}
 </p>
 % endif
 
-% if recent_games:
-<h2>Recent Games</h2>
-% for (gamestat, game, server, map) in recent_games:
-   <a href="${request.route_url("game_info", id=game.game_id)}" name="Game info page for game #${game.game_id}">#${game.game_id}:</a> <a href="${request.route_url("map_info", id=map.map_id)}" name="Map info page for ${map.name}">${map.name}</a> on <a href="${request.route_url("server_info", id=server.server_id)}" name="Server info page for ${server.name}">${server.name}</a>
-<br />
-% endfor
-<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
-
 
+##### ACCURACY #####
 % if weapon_stats:
 <h2>Accuracy</h2>
-<table border="1" cellpadding="3" align="center">
-<tr>
+<table class="accuracy-table" border="1" cellpadding="3" align="center">
+<tr class="accuracy-table-header">
     <td></td>
     <td>Weapon</td>
     <td>Hit</td>
@@ -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
 %>
 <tr>
-    <td>[IMAGE]</td>
-    <td>${weapon_stat[0]}</td>
-    <td>${weapon_stat[3]}</td>
+    ## 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[1]}</td>
     <td>${weapon_stat[2]}</td>
+    <td>${weapon_stat[3]}</td>
     <td>${damage_pct}%</td>
 </tr>
 % endfor
 </table>
 
 % endif
+
+##### RECENT GAMES #####
+% if recent_games:
+<h2>Recent Games</h2>
+% for (gamestat, game, server, map) in recent_games:
+   <a href="${request.route_url("game_info", id=game.game_id)}" name="Game info page for game #${game.game_id}">#${game.game_id}:</a> <a href="${request.route_url("map_info", id=map.map_id)}" name="Map info page for ${map.name}">${map.name}</a> on <a href="${request.route_url("server_info", id=server.server_id)}" name="Server info page for ${server.name}">${server.name}</a>
+<br />
+% endfor
+<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
+
+
index 9337b834b05cda1d88f3c229d7db7cb9577c7a1e..8db3c556b170345be289c448d1fe96f6056fd1d7 100755 (executable)
@@ -28,16 +28,16 @@ def player_info(request):
     try:\r
         player = DBSession.query(Player).filter_by(player_id=player_id).one()\r
 \r
-        weapon_stats = DBSession.query("descr", "actual_total", \r
+        weapon_stats = DBSession.query("descr", "weapon_cd", "actual_total", \r
                 "max_total", "hit_total", "fired_total", "frags_total").\\r
                 from_statement(\r
-                    "select cw.descr, sum(actual) actual_total, "\r
+                    "select cw.descr, cw.weapon_cd, sum(actual) actual_total, "\r
                     "sum(max) max_total, sum(hit) hit_total, "\r
                     "sum(fired) fired_total, sum(frags) frags_total "\r
                     "from xonstat.player_weapon_stats ws, xonstat.cd_weapon cw "\r
                     "where ws.weapon_cd = cw.weapon_cd "\r
                     "and player_id = :player_id "\r
-                    "group by descr "\r
+                    "group by descr, cw.weapon_cd "\r
                     "order by descr"\r
                 ).params(player_id=player_id).all()\r
 \r