Module:Sandbox/One Bar: Difference between revisions

One Bar (talk | contribs)
No edit summary
m Mgpt moved page Module:One Bar/Sandbox to Module:Sandbox/One Bar: Deadlock:User pages
 
(13 intermediate revisions by one other user not shown)
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 function format_spirit_scale(frame, key, base, scale)
local burst_heroes = {}
local spirit_scale = frame:expandTemplate{ title = "ss", args = {(scale or 0)}}
local spreadshot_heroes = {}
return key ..": ".. (base or 0) .. "+" .. spirit_scale .. "\n"
for _, hero in pairs(heroes_data) do
end
if (hero["BulletsPerShot"] > 1 and not hero["IsDisabled"]) then
 
table.insert(spreadshot_heroes, hero)
local function get_stats_spirit_scaling(frame, hero)
elseif (hero["BulletsPerBurst"] > 1 and not hero["IsDisabled"]) then
local spirit_scaling = hero["SpiritScaling"]
table.insert(burst_heroes, hero)
stats_text = ""
if (spirit_scaling ~= nil) then
for k, v in pairs(spirit_scaling) do
stats_text = stats_text .. format_spirit_scale(frame, k, hero[k], v)
end
end
else
stats_text = "-"
end
end
return stats_text
local multishot_str = "Weapons with multiple projectiles (Spreadshot):\n"
end
for _, hero in ipairs(spreadshot_heroes) do
 
local base = math.floor(hero["BulletDamage"] * 100) / 100
local function get_abilities_spirit_scaling(frame, hero_key, hero)
local level = math.floor(hero["LevelScaling"]["BulletDamage"] * 100) / 100
local ret = {}
local shots = hero["BulletsPerShot"]
for i=1,4 do
local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}}
local ability = ability_data[hero_key][i]
local stat_str = "* " .. hero_icon .. ": " .. shots .. " pellets, "  
local ability_text = ""
.. base .. "/pellet, +" .. level .. "/pellet\n"
if (ability ~= nil) then
multishot_str = multishot_str .. stat_str
ret[i*2-1] = ability["Name"]
if (ability["Info1"] ~= nil and ability["Info1"]["Main"] ~= nil
and ability["Info1"]["Main"]["Props"] ~= nil) then
for _, prop in ipairs(ability["Info1"]["Main"]["Props"]) do
if (prop["Scale"] ~= nil and prop["Scale"]["Type"] == "spirit" and prop["Scale"]["Value"] ~= 0) then
ability_text = ability_text .. format_spirit_scale(frame, prop["Name"], prop["Value"], prop["Scale"]["Value"])
end
end
end
else
ret[i*2-1] = "-"
end
if (ability_text == "") then
ability_text = "-"
end
ret[i*2] = ability_text
end
end
return ret
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
end


-- Outputs a wikitable of heroes and their stats' and abilities' spirit scaling
-- @function  p.write_spirit_scaling_table
-- @param      {}
-- @return    {string}
p.write_spirit_scaling_table = function(frame)
p.write_spirit_scaling_table = function(frame)
local filtered_heroes = {}
local filtered_heroes = {}
local hero_keys = {}
for hero_key, hero in pairs(heroes_data) do
for hero_key, hero in pairs(heroes_data) do
if (not hero["IsDisabled"]) then
if (not hero["IsDisabled"] and not hero["InDevelopment"]) then
filtered_heroes[hero_key] = hero
local hero_data = {["hero"] = hero; ["hero_key"] = hero_key}
table.insert(filtered_heroes, hero_data)
end
end
end
end
table.sort(filtered_heroes, function(a, b) return a.hero.Name:lower() < b.hero.Name:lower() end)
local create_table = mw.html.create("table"):addClass("wikitable sortable"):done()
local create_table = mw.html.create("table"):addClass("wikitable sortable"):done()
Line 52: Line 67:
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 59: Line 73:
create_table:node(header)
create_table:node(header)
for hero_key, hero in pairs(filtered_heroes) do
for _, hero_data in ipairs(filtered_heroes) do
local spirit_scaling = hero["SpiritScaling"]
local hero = hero_data.hero
local hero_key = hero_data.hero_key
local hero_row = mw.html.create("tr")
local hero_row = mw.html.create("tr")
stats_text = ""
local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}}
if (spirit_scaling ~= nil and next(spirit_scaling) ~= nil) then
hero_row:tag('td'):wikitext(hero_icon):done()
for k, v in ipairs(spirit_scaling) do
local abilities = get_abilities_spirit_scaling(frame, hero_key, hero)
stats_text = stats_text .. k ..": ".. hero[k] .. "+" .. v .. "\n"
for i=1,8 do
end
hero_row:tag('td'):wikitext(abilities[i]):done()
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
if (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)