]> de.git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Add basic display of player weapon stats.
authorAnt Zucaro <azucaro@gmail.com>
Sat, 21 May 2011 12:19:22 +0000 (08:19 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Sat, 21 May 2011 12:19:22 +0000 (08:19 -0400)
xonstat/__init__.py
xonstat/templates/player_weapon_stats.mako [new file with mode: 0644]
xonstat/views.py

index d317443a9e3be74efc5ccb0ccdfa6b5a2ec08604..703932735bd01eb5ed097430957c976c13187827 100755 (executable)
@@ -26,6 +26,10 @@ def main(global_config, **settings):
             renderer='game_index.mako') 
 
     # PLAYER ROUTES
+    config.add_route(name="player_weapon_stats", 
+            pattern="/game/{game_id:\d+}/stats/{pgstat_id:\d+}", 
+            view=player_weapon_stats, renderer='player_weapon_stats.mako') 
+
     config.add_route(name="player_game_index", 
             pattern="/player/{player_id:\d+}/games/page/{page:\d+}", 
             view=player_game_index, renderer='player_game_index.mako') 
diff --git a/xonstat/templates/player_weapon_stats.mako b/xonstat/templates/player_weapon_stats.mako
new file mode 100644 (file)
index 0000000..1a499f1
--- /dev/null
@@ -0,0 +1,35 @@
+<%inherit file="base.mako"/>
+
+<%block name="title">
+Accuracy Information - ${parent.title()}
+</%block>
+
+
+% if pwstats is None:
+<h2>Sorry, I can't find those weapon stats!</h2>
+<p>Assume the best, though. Really.</p>
+
+% else:
+<h2>Player Accuracy:</h2>
+<table border="1" cellpadding="3">
+    <tr>
+        <td>Weapon</td>
+        <td>Fired</td>
+        <td>Hit</td>
+        <td>Potential Damage</td>
+        <td>Actual Damage</td>
+        <td>Frags</td>
+    </tr>
+
+% for pwstat in pwstats:
+    <tr>
+        <td>${pwstat.weapon_cd}</td>
+        <td>${pwstat.fired}</td>
+        <td>${pwstat.hit}</td>
+        <td>${pwstat.max}</td>
+        <td>${pwstat.actual}</td>
+        <td>${pwstat.frags}</td>
+    </tr>
+% endfor
+</table>
+% endif
index 2643fe58f62fad8fbf65af914705383359affd0e..b78d97c41f9b5e424c02a1544e7a999cf0b8f14d 100755 (executable)
@@ -78,6 +78,21 @@ def player_game_index(request):
             'games':games}
 
 
+def player_weapon_stats(request):
+    game_id = request.matchdict['game_id']
+    pgstat_id = request.matchdict['pgstat_id']
+    try:
+        pwstats = DBSession.query(PlayerWeaponStat).\
+                filter_by(game_id=game_id).\
+                filter_by(player_game_stat_id=pgstat_id).\
+                order_by(PlayerWeaponStat.weapon_cd).\
+                all()
+
+    except Exception as e:
+        pwstats = None
+    return {'pwstats':pwstats}
+
+
 ##########################################################################
 # This is the game views area - only views pertaining to Xonotic
 # games and their related information goes here