Module:Armor info
Jump to navigation
Jump to search
armorDamageTable
displays a chart of damage taken based on armor defense points and incoming attack strength.
[view] [edit] [history] [refresh]The above documentation is transcluded from Module:Armor info/doc.
local p = {}
local function armorDamage( damage, defensePoints )
return damage * ( 1 - math.max( defensePoints / 5, defensePoints - damage / 2 ) / 25 )
end
function p.armorDamageTable( frame )
local t = {}
local r
table.insert( t, '{| class="wikitable" style="text-align:center"' )
table.insert( t, '|-' )
table.insert( t, '!rowspan=2| Armor' )
table.insert( t, '!colspan=20| Attack damage' )
r = {}
for i = 1, 20 do
table.insert( r, i )
end
table.insert( t, '|-' )
table.insert( t, '! ' .. table.concat( r, ' !! ' ) )
for defensePoints = 0, 20 do
r = {}
for damage = 1, 20 do
table.insert( r, string.format( '%.2f', armorDamage( damage, defensePoints ) ) )
end
table.insert( t, '|-' )
table.insert( t, '! ' .. defensePoints )
table.insert( t, '| ' .. table.concat( r, ' || ' ) )
end
table.insert( t, '|}' )
return table.concat( t, '\n' )
end
return p