Remove Persona since it was shut down. :(
[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 ## [6] = Frags
14
15 <table class="table-hover table-condensed">
16   <thead>
17     <th class="small-2 medium-1"></th>
18     <th class="show-for-medium-up">Weapon</th>
19     <th class="show-for-medium-up">Frags</th>
20     <th>Accuracy</th>
21     <th>Damage</th>
22   </thead>
23
24   <%
25     total_damage = 0
26     for weapon_stat in weapon_stats:
27       total_damage += weapon_stat[2]
28     if total_damage == 0:
29       total_damage = 1
30   %>
31
32   % for weapon_stat in weapon_stats:
33     <%
34       if weapon_stat[3] > 0: 
35         damage_pct = round(float(weapon_stat[2])/weapon_stat[3]*100, 2)
36       else:
37         damage_pct = 0
38
39       if weapon_stat[5] > 0: 
40         hit_pct = round(float(weapon_stat[4])/weapon_stat[5]*100, 2)
41       else:
42         hit_pct = 0
43     %>
44     <tr>
45       ## Note: the name of the image must match up with the weapon_cd 
46       ## entry of that weapon, else this won't work
47       <td class="small-2 medium-1 text-center"><span class="sprite sprite-${weapon_stat[1]}"></span></td>
48       <td class="show-for-medium-up">${weapon_stat[0]}</td>
49       <td class="show-for-medium-up">${weapon_stat[6]}</td>
50       <td>${weapon_stat[4]}/${weapon_stat[5]} (${hit_pct}%)</td>
51       <td>${weapon_stat[2]} (${round(float(weapon_stat[2])/total_damage*100, 2)}%)</td>
52     </tr>
53   % endfor
54 </table>
55 </%def>