Module:Damage: Difference between revisions
From Elwiki
No edit summary |
No edit summary |
||
Line 33: | Line 33: | ||
function p.getHeavy(frame) | function p.getHeavy(frame) | ||
return getArgs(frame)[1] * 1.44 | |||
return | end | ||
function p.getPassive1(frame) | |||
return getArgs(frame)[1] * 1.25 | |||
end | end | ||
return p | return p |
Revision as of 21:33, 23 March 2022
Documentation for this module may be created at Module:Damage/doc
local getArgs = require('Module:Arguments').getArgs
local p = {}
function string.starts(String,Start)
return string.sub(String,1,string.len(Start))==Start
end
function spairs(t)
local keys = {}
for k in pairs(t) do keys[#keys+1] = k end
table.sort(keys)
local i = 0
return function()
i = i + 1
if keys[i] then
return keys[i], t[keys[i]]
end
end
end
function p.getTotal(frame)
local args = getArgs(frame)
local tab = 0
local i = 1
for k,v in spairs(args) do
if string.starts(k, 'dmg') then
tab = tab + args['dmg' .. i] * args['hits' .. i]
i = i + 1
end
end
-- return frame:preprocess('{{formatnum:'..tab..'}}%')
return tab
end
function p.getHeavy(frame)
return getArgs(frame)[1] * 1.44
end
function p.getPassive1(frame)
return getArgs(frame)[1] * 1.25
end
return p