Editing Module:Sandbox/One BarGive feedback
Jump to navigation
Jump to search
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
| Latest revision | Your text | ||
| Line 4: | Line 4: | ||
local ability_data = mw.loadJsonData("Data:AbilityCards.json") | local ability_data = mw.loadJsonData("Data:AbilityCards.json") | ||
p.write_multishot_stats = function(frame) | |||
local | local function hero_sort(h1, h2) | ||
return h1["Name"] < h2["Name"] | |||
end | end | ||
local spreadshot_heroes = {} | |||
local | local burst_heroes = {} | ||
for _, hero in pairs(heroes_data) do | |||
if (hero["BulletsPerShot"] > 1 and not hero["IsDisabled"]) then | |||
table.insert(spreadshot_heroes, hero) | |||
elseif (hero["BulletsPerBurst"] > 1 and not hero["IsDisabled"]) then | |||
table.insert(burst_heroes, hero) | |||
end | end | ||
end | end | ||
table.sort(spreadshot_heroes, hero_sort) | |||
table.sort(burst_heroes, hero_sort) | |||
local | local multishot_str = "Weapons with multiple projectiles (Spreadshot):\n" | ||
for | for _, hero in ipairs(spreadshot_heroes) do | ||
local | local base = math.floor(hero["BulletDamage"] * 100) / 100 | ||
local | 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 | end | ||
return | |||
return multishot_str | |||
end | end | ||
p.write_spirit_scaling_table = function(frame) | p.write_spirit_scaling_table = function(frame) | ||
local filtered_heroes = {} | local filtered_heroes = {} | ||
for hero_key, hero in pairs(heroes_data) do | for hero_key, hero in pairs(heroes_data) do | ||
if (not hero["IsDisabled | if (not hero["IsDisabled"]) then | ||
filtered_heroes[hero_key] = hero | |||
end | end | ||
end | end | ||
local create_table = mw.html.create("table"):addClass("wikitable sortable"):done() | local create_table = mw.html.create("table"):addClass("wikitable sortable"):done() | ||
| Line 67: | Line 58: | ||
header | header | ||
:tag("th"):wikitext("Hero"):done() | :tag("th"):wikitext("Hero"):done() | ||
:tag("th"):wikitext("Stats"):done() | |||
:tag("th"):attr("colspan", 2):wikitext("First Skill"):done() | :tag("th"):attr("colspan", 2):wikitext("First Skill"):done() | ||
:tag("th"):attr("colspan", 2):wikitext("Second Skill"):done() | :tag("th"):attr("colspan", 2):wikitext("Second Skill"):done() | ||
| Line 73: | Line 65: | ||
create_table:node(header) | create_table:node(header) | ||
for | for hero_key, hero in pairs(filtered_heroes) do | ||
local | local spirit_scaling = hero["SpiritScaling"] | ||
local hero_row = mw.html.create("tr") | local hero_row = mw.html.create("tr") | ||
stats_text = "" | |||
hero_row:tag('td'):wikitext( | if (spirit_scaling ~= nil and next(spirit_scaling) ~= nil) then | ||
local | for k, v in ipairs(spirit_scaling) do | ||
stats_text = stats_text .. k ..": ".. hero[k] .. "+" .. v .. "\n" | |||
hero_row:tag('td'):wikitext( | end | ||
else | |||
stats_text = "-" | |||
end | |||
hero_row:tag('td'):wikitext(hero_text):done() | |||
for i=1,4 do | |||
local ability = ability_data[hero_key][i] | |||
hero_row:tag('td'):wikitext(ability["Name"]):done() | |||
local ability_text = "" | |||
-- Nowhere close to all the instances of ability spirit scaling | |||
-- probably too much nil check but I want the table to print for now | |||
if (ability["Info1"] ~= nil and ability["Info1"]["Main"] ~= nil | |||
and ability["Info1"]["Main"]["Props"] ~= nil | |||
and next(ability["Info1"]["Main"]["Props"]) ~= nil) then | |||
for _, prop in ipairs(ability["Info1"]["Main"]["Props"]) do | |||
if (prop["Scale"] ~= nil and next(prop["Scale"]) ~= nil) then | |||
ability_text = ability_text .. prop["Name"] ..": " | |||
.. prop["Value"] .. " + " .. prop["Scale"]["Value"] .. "\n" | |||
end | |||
end | |||
else | |||
ability_text = "-" | |||
end | |||
hero_row:tag('td'):wikitext(ability_text):done() | |||
end | end | ||
create_table:node(hero_row) | create_table:node(hero_row) | ||