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
 
(21 intermediate revisions by one other user not shown)
Line 2: Line 2:
local item_data = mw.loadJsonData("Data:ItemData.json")
local item_data = mw.loadJsonData("Data:ItemData.json")
local heroes_data = mw.loadJsonData("Data:HeroData.json")
local heroes_data = mw.loadJsonData("Data:HeroData.json")
local soul_unlocks_data = mw.loadJsonData("Data:SoulUnlockData.json")
local ability_data = mw.loadJsonData("Data:AbilityCards.json")


local level_scaling_key_to_name = {
local function format_spirit_scale(frame, key, base, scale)
BulletDamage = "Bullet Damage",
local spirit_scale = frame:expandTemplate{ title = "ss", args = {(scale or 0)}}
MaxHealth = "Health",
return key ..": ".. (base or 0) .. "+" .. spirit_scale .. "\n"
TechPower = "Spirit Power",
end
LightMeleeDamage = "Light Melee Damage",
HeavyMeleeDamage = "Heavy Melee Damage"
}


-- Not in HeroData.json although Shiv is just (bullet damage * 12)
local function get_stats_spirit_scaling(frame, hero)
local alt_fires = {
local spirit_scaling = hero["SpiritScaling"]
Shiv = {base = 59.4, level = 2.64, suffix = "alt fire 12 pellets"},
stats_text = ""
Viscous = {base = 70, level = 0.9, suffix = "alt fire AOE"},
if (spirit_scaling ~= nil) then
Yamato = {base = 70, level = 0.35, suffix = "alt fire AOE"}
for k, v in pairs(spirit_scaling) do
}
stats_text = stats_text .. format_spirit_scale(frame, k, hero[k], v)
end
else
stats_text = "-"
end
return stats_text
end


p.pi_table = function(frame)
local function get_abilities_spirit_scaling(frame, hero_key, hero)
local pi_souls_list = {}
local ret = {}
for _, v in ipairs(soul_unlocks_data) do
for i=1,4 do
if (v["PowerIncrease"]) then
local ability = ability_data[hero_key][i]
table.insert(pi_souls_list, v["RequiredSouls"])
local ability_text = ""
if (ability ~= nil) then
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
end
ret[i*2] = ability_text
end
end
local level_count = 0
return ret
for _ in ipairs(pi_souls_list) do level_count = level_count + 1 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)
local filtered_heroes = {}
local filtered_heroes = {}
for _, hero in pairs(heroes_data) do
local hero_keys = {}
if (not hero["IsDisabled"]) then
for hero_key, hero in pairs(heroes_data) do
table.insert(filtered_heroes, hero)
if (not hero["IsDisabled"] and not hero["InDevelopment"]) then
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 property = frame.args[1] --frame:getParent().args[1]
local create_table = mw.html.create("table"):addClass("wikitable sortable"):done()
local name = level_scaling_key_to_name[property]
local header = mw.html.create("tr")
local suffix = property == "BulletDamage" and " (Full Shot)" or ""
header
:tag("th"):wikitext("Hero"):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("Third Skill"):done()
:tag("th"):attr("colspan", 2):wikitext("Ultimate"):done()
create_table:node(header)
local create_div = mw.html.create("div"):css("overflow-x", "auto")
for _, hero_data in ipairs(filtered_heroes) do
local create_table = mw.html.create("table"):addClass("wikitable sortable mw-collapsible mw-collapsed"):done()
local hero = hero_data.hero
local hero_key = hero_data.hero_key
local title_header = mw.html.create("tr")
local hero_row = mw.html.create("tr")
title_header:tag("th"):attr("colspan", (level_count + 3)):wikitext("Base " .. name .. " based on PI"):done()
create_table:node(title_header)
local label_header = mw.html.create("tr")
label_header
:tag("th"):attr("rowspan", 2):wikitext("Hero"):done()
:tag("th"):attr("rowspan", 2):wikitext("Base " .. name .. suffix):done()
:tag("th"):attr("rowspan", 2):wikitext("PL Increase" .. suffix):done()
:tag("th"):attr("colspan", level_count):wikitext("Souls Collected"):done()
create_table:node(label_header)
local souls_header = mw.html.create("tr")
for _, v in ipairs(pi_souls_list) do
local souls_formatted = string.format("%.1fK", (v + 400) / 1000)
souls_formatted = frame:expandTemplate{ title = "Souls", args = {souls_formatted}}
souls_header:tag("th"):wikitext(souls_formatted):done()
end
create_table:node(souls_header)
for _, hero in ipairs(filtered_heroes) do
local base = math.floor((hero[property] or 0) * 100) / 100
local level = math.floor(hero["LevelScaling"][property] * 100) / 100
local shots = hero["BulletsPerShot"]
local burst = hero["BulletsPerBurst"]
local bullet_mult = shots * burst
local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}}
local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}}
local hero_suffix = ""
hero_row:tag('td'):wikitext(hero_icon):done()
if (property == "BulletDamage" and bullet_mult > 1) then
local abilities = get_abilities_spirit_scaling(frame, hero_key, hero)
base = base * bullet_mult
for i=1,8 do
level = level * bullet_mult
hero_row:tag('td'):wikitext(abilities[i]):done()
if (shots > 1) then hero_suffix = hero_suffix .. " (" .. shots .. " pellets)" end
if (burst > 1) then hero_suffix = hero_suffix .. " (" .. burst .. " bullets)" end
end
local hero_row = mw.html.create("tr")
hero_row
:tag("td"):wikitext(hero_icon .. hero_suffix):done()
:tag("td"):wikitext(base):done()
:tag("td"):wikitext("+" .. level):done()
for i, v in ipairs(pi_souls_list) do
local total = (tonumber(base) ~= nil and base or 0) + (tonumber(level) ~= nil and level or 0)  * i
hero_row
:tag("td"):wikitext(total):done()
end
end
create_table:node(hero_row)
create_table:node(hero_row)
if (property == "BulletDamage" and alt_fires[hero["Name"]] ~= nil) then
local alt_fire = alt_fires[hero["Name"]]
local alt_base = alt_fire["base"]
local alt_level = alt_fire["level"]
local alt_suffix = " (" .. alt_fire["suffix"] .. ")"
local alt_fire_row = mw.html.create("tr")
alt_fire_row
:tag("td"):wikitext(hero_icon .. alt_suffix):done()
:tag("td"):wikitext(alt_base):done()
:tag("td"):wikitext("+" .. alt_level):done()
for i, v in ipairs(pi_souls_list) do
local total = alt_base + alt_level * i
alt_fire_row:tag("td"):wikitext(total):done()
end
create_table:node(alt_fire_row)
end
end
end
create_div:node(create_table)
return tostring(create_table)
return tostring(create_div)
end
end