Module:Sandbox/LVL: Difference between revisions

Jump to navigation Jump to search
LVL (talk | contribs)
No edit summary
LVL (talk | contribs)
No edit summary
Line 32: Line 32:
--]]
--]]
p.write_power_increase_table = function(frame)
p.write_power_increase_table = function(frame)
-- Read and validate the arguments passed from the #invoke call.
local property = frame.args[1]
local property = frame.args[1]
local title = frame.args.title
local title = frame.args.title
Line 224: Line 223:
return tostring(create_table)
return tostring(create_table)
end
end
end
--[[
-- @function p.write_multishot_stats
-- @description Outputs a wikitext bulleted list of heroes with spreadshot or burst fire weapons.
-- @param {Frame} frame The MediaWiki frame object.
-- @return {string} A formatted wikitext string.
--]]
p.write_multishot_stats = function(frame)
local function hero_sort(h1, h2)
return h1["Name"] < h2["Name"]
end
local spreadshot_heroes = {}
local burst_heroes = {}
for _, hero in pairs(heroes_data) do
if ((hero["BulletsPerShot"] or 1) > 1 and not hero["IsDisabled"]) then
table.insert(spreadshot_heroes, hero)
elseif ((hero["BulletsPerBurst"] or 1) > 1 and not hero["IsDisabled"]) then
table.insert(burst_heroes, hero)
end
end
table.sort(spreadshot_heroes, hero_sort)
table.sort(burst_heroes, hero_sort)
local multishot_str = "Weapons with multiple projectiles (Spreadshot):\n"
for _, hero in ipairs(spreadshot_heroes) do
local base = math.floor(hero["BulletDamage"] * 100) / 100
local level = math.floor(hero["LevelScaling"]["BulletDamage"] * 100) / 100
local shots = hero["BulletsPerShot"]
local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}}
local stat_str = "* " .. hero_icon .. ": " .. shots .. " pellets, "
.. base .. "/pellet, +" .. level .. "/pellet\n"
multishot_str = multishot_str .. stat_str
end
multishot_str = multishot_str .. "Weapons with burst fire (Burst Fire):\n"
for _, hero in ipairs(burst_heroes) do
local base = math.floor(hero["BulletDamage"] * 100) / 100
local level = math.floor(hero["LevelScaling"]["BulletDamage"] * 100) / 100
local shots = hero["BulletsPerBurst"]
local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}}
local stat_str = "* " .. hero_icon .. ": " .. shots .. " rounds, "
.. base .. "/bullet, +" .. level .. "/bullet\n"
multishot_str = multishot_str .. stat_str
end
return multishot_str
end
end


return p
return p