]> git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Add the actual accuracy template (whoops).
authorAnt Zucaro <azucaro@gmail.com>
Thu, 26 May 2011 17:05:05 +0000 (13:05 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Thu, 26 May 2011 17:05:05 +0000 (13:05 -0400)
xonstat/templates/accuracy.mako [new file with mode: 0755]

diff --git a/xonstat/templates/accuracy.mako b/xonstat/templates/accuracy.mako
new file mode 100755 (executable)
index 0000000..f8b9db7
--- /dev/null
@@ -0,0 +1,50 @@
+<%def name="accuracy(weapon_stats)">
+
+## Parameters: 
+## weapon_stats is an array containing what we'll call "weapon_stat"
+## objects. These objects have the following attributes:
+##
+## [0] = Weapon description
+## [1] = Weapon code
+## [2] = Actual damage
+## [3] = Max damage
+## [4] = Hit
+## [5] = Fired
+
+<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[3] > 0: 
+    damage_pct = round(float(weapon_stat[2])/weapon_stat[3]*100, 2)
+else:
+    damage_pct = 0
+if weapon_stat[5] > 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>
+</%def>