Module:Armor info

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