Module:Sandbox/One Bar: Difference between revisions

One Bar (talk | contribs)
No edit summary
One Bar (talk | contribs)
No edit summary
Line 3: Line 3:
local heroes_data = mw.loadJsonData("Data:HeroData.json")
local heroes_data = mw.loadJsonData("Data:HeroData.json")
local ability_data = mw.loadJsonData("Data:AbilityCards.json")
local ability_data = mw.loadJsonData("Data:AbilityCards.json")
local function format_spirit_scale(frame, key, base, scale)
local spirit_scale = frame:expandTemplate{ title = "ss", args = {(scale or 0)}}
return key ..": ".. (base or 0) .. "+" .. spirit_scale .. "\n"
end


-- Outputs a wikitable of heroes and their stats' and abilities' spirit scaling
-- Outputs a wikitable of heroes and their stats' and abilities' spirit scaling
Line 35: Line 40:
if (spirit_scaling ~= nil) then
if (spirit_scaling ~= nil) then
for k, v in pairs(spirit_scaling) do
for k, v in pairs(spirit_scaling) do
stats_text = stats_text .. (k or "nil") ..": ".. (hero[k] or "nil") .. "+" .. (v or "nil") .. "\n"
stats_text = stats_text .. format_spirit_scale(k, hero[k], v)
end
end
else
else
Line 51: Line 56:
for _, prop in ipairs(ability["Info1"]["Main"]["Props"]) do
for _, prop in ipairs(ability["Info1"]["Main"]["Props"]) do
if (prop["Scale"] ~= nil and next(prop["Scale"]) ~= nil) then
if (prop["Scale"] ~= nil and next(prop["Scale"]) ~= nil) then
ability_text = ability_text .. (prop["Name"] or "nil") ..": "
ability_text = ability_text .. format_spirit_scale(prop["Name"], prop["Value"], prop["Scale"]["Value"])
.. (prop["Value"] or "nil") .. " + " .. (prop["Scale"]["Value"] or "nil") .. "\n"
end
end
end
end