%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 ## [6] = Frags
Weapon | Frags | Accuracy | Damage | <% total_damage = 0 for weapon_stat in weapon_stats: total_damage += weapon_stat[2] if total_damage == 0: total_damage = 1 %> % 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 %>|
---|---|---|---|---|
${weapon_stat[0]} | ${weapon_stat[6]} | ${weapon_stat[4]}/${weapon_stat[5]} (${hit_pct}%) | ${weapon_stat[2]} (${round(float(weapon_stat[2])/total_damage*100, 2)}%) |