Module:Sandbox/One Bar: Difference between revisionsGive feedback
No edit summary |
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") | ||
p.write_multishot_stats = function(frame) | |||
local burst_heroes = {} | |||
local spreadshot_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 | |||
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 string.trim(multishot_str) | |||
end | |||
p.write_spirit_scaling_table = function(frame) | p.write_spirit_scaling_table = function(frame) | ||
| Line 24: | Line 60: | ||
for hero_key, hero in pairs(filtered_heroes) do | 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 = "" | stats_text = "" | ||
if ( | if (spirit_scaling ~= nil and next(spirit_scaling) ~= nil) then | ||
for k, v in ipairs( | for k, v in ipairs(spirit_scaling) do | ||
stats_text = stats_text .. k ..": ".. hero[k] .. "+" .. v .. "\n" | stats_text = stats_text .. k ..": ".. hero[k] .. "+" .. v .. "\n" | ||
end | end | ||
| Line 36: | Line 72: | ||
hero_row:tag('td'):wikitext(hero_text):done() | hero_row:tag('td'):wikitext(hero_text):done() | ||
for i=1,4 do | for i=1,4 do | ||
local ability = ability_data[hero_key][ | local ability = ability_data[hero_key][i] | ||
hero_row:tag('td'):wikitext(ability["Name"]):done() | hero_row:tag('td'):wikitext(ability["Name"]):done() | ||
local ability_text = "" | local ability_text = "" | ||