Editing Module:Sandbox/One BarGive feedback
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 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 | local soul_unlocks_data = mw.loadJsonData("Data:SoulUnlockData.json") | ||
local function | local function souls(frame, item) | ||
return frame:expandTemplate{ title = "Souls", args = {item}} | |||
end | end | ||
local function | local function hero_icon(frame, hero) | ||
local | return frame:expandTemplate{ title = "HeroIcon", args = {hero}} | ||
end | |||
local key_to_name = { | |||
BulletDamage = "Bullet Damage", | |||
MaxHealth = "Health", | |||
TechPower = "Spirit Power", | |||
LightMeleeDamage = "Light Melee Damage", | |||
HeavyMeleeDamage = "Heavy Melee Damage" | |||
} | |||
-- Not in HeroData.json although Shiv is just (bullet damage * 12) | |||
local alt_fires = { | |||
Shiv = {base = 59.4, level = 2.64, suffix = "alt fire 12 pellets"}, | |||
Viscous = {base = 70, level = 0.9, suffix = "alt fire AOE"}, | |||
Yamato = {base = 70, level = 0.35, suffix = "alt fire AOE"} | |||
} | |||
local function filtered_heroes() | |||
local filtered = {} | |||
for _, hero in pairs(heroes_data) do | |||
if (not hero["IsDisabled"]) then | |||
table.insert(filtered, hero) | |||
end | end | ||
end | end | ||
return | return filtered | ||
end | end | ||
local function | local function get_pi_list() | ||
local | local soul_pis = {} | ||
for _, v in ipairs(soul_unlocks_data) do | |||
if (v["PowerIncrease"]) then | |||
table.insert(soul_pis, v["RequiredSouls"]) | |||
end | end | ||
end | end | ||
return | return soul_pis | ||
end | end | ||
p.pi_table = function(frame) | |||
local pi_souls_list = get_pi_list() | |||
local level_count = 0 | |||
for _ in ipairs(pi_souls_list) do level_count = level_count + 1 end | |||
local property = frame.args[1] --frame:getParent().args[1] | |||
local | local name = key_to_name[property] | ||
local | local suffix = property == "BulletDamage" and " (Full Shot)" or "" | ||
for | |||
local createTable = mw.html.create("table"):addClass("wikitable sortable mw-collapsible"):done() | |||
local header1 = mw.html.create("tr") | |||
header1:tag("th"):attr("colspan", (level_count + 3)):wikitext("Base " .. name .. " based on PI"):done() | |||
createTable:node(header1) | |||
local header2 = mw.html.create("tr") | |||
header2 | |||
: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() | |||
createTable:node(header2) | |||
local createTableHeader = mw.html.create("tr") | |||
for _, v in ipairs(pi_souls_list) do | |||
local souls_formatted = string.format("%.1fK", (v + 400) / 1000) | |||
createTableHeader:tag("th"):wikitext(souls(frame, souls_formatted)):done() | |||
end | end | ||
createTable:node(createTableHeader) | |||
local | local filtered_heroes = filtered_heroes() | ||
for _, hero in ipairs(filtered_heroes) do | |||
local base = math.floor(hero[property] * 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_suffix = "" | |||
if (property == "BulletDamage" and bullet_mult > 1) then | |||
base = base * bullet_mult | |||
level = level * bullet_mult | |||
if (shots > 1) then hero_suffix = hero_suffix .. " (" .. shots .. " pellets)" end | |||
if (burst > 1) then hero_suffix = hero_suffix .. " (" .. burst .. " bullets)" end | |||
end | |||
local tableData = mw.html.create("tr") | |||
tableData | |||
:tag("td"):wikitext(hero_icon(frame, hero["Name"]) .. hero_suffix):done() | |||
for i | :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 | |||
tableData | |||
:tag("td"):wikitext(total):done() | |||
end | |||
createTable:node(tableData) | |||
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(frame, hero["Name"]) .. 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 | |||
createTable:node(alt_fire_row) | |||
end | end | ||
end | end | ||
return tostring( | return tostring(createTable) | ||
end | end | ||