]> de.git.xonotic.org Git - xonotic/xonstat.git/blob - xonstat/templates/accuracy.mako
dos2unix file conversions for everything
[xonotic/xonstat.git] / xonstat / templates / accuracy.mako
1 <%def name="accuracy(weapon_stats)">
2
3 ## Parameters: 
4 ## weapon_stats is an array containing what we'll call "weapon_stat"
5 ## objects. These objects have the following attributes:
6 ##
7 ## [0] = Weapon description
8 ## [1] = Weapon code
9 ## [2] = Actual damage
10 ## [3] = Max damage
11 ## [4] = Hit
12 ## [5] = Fired
13
14 <table class="table table-bordered table-condensed">
15 <thead>
16     <th></th>
17     <th>Weapon</th>
18     <th>Hit</th>
19     <th>Fired</th>
20     <th>Hit %</th>
21     <th>Actual Damage</th>
22     <th>Potential Damage</th>
23     <th>Damage %</th>
24 </thead>
25 % for weapon_stat in weapon_stats:
26 <%
27 if weapon_stat[3] > 0: 
28     damage_pct = round(float(weapon_stat[2])/weapon_stat[3]*100, 2)
29 else:
30     damage_pct = 0
31 if weapon_stat[5] > 0: 
32     hit_pct = round(float(weapon_stat[4])/weapon_stat[5]*100, 2)
33 else:
34     hit_pct = 0
35 %>
36 <tr>
37     ## Note: the name of the image must match up with the weapon_cd 
38     ## entry of that weapon, else this won't work
39     <td><img src="${request.static_url("xonstat:static/images/%s.png" % weapon_stat[1])}" /></td>
40     <td>${weapon_stat[0]}</td>
41     <td>${weapon_stat[4]}</td>
42     <td>${weapon_stat[5]}</td>
43     <td>${hit_pct}%</td>
44     <td>${weapon_stat[2]}</td>
45     <td>${weapon_stat[3]}</td>
46     <td>${damage_pct}%</td>
47 </tr>
48 % endfor
49 </table>
50 </%def>