Module:Sandbox/One Bar: Difference between revisionsGive feedback
Jump to navigation
Jump to search
alt fires |
rounding |
||
| Line 55: | Line 55: | ||
local suffix = property == "BulletDamage" and " (Full Shot)" or "" | local suffix = property == "BulletDamage" and " (Full Shot)" or "" | ||
local createTable = mw.html.create("table"):addClass("wikitable sortable"):done() | local createTable = mw.html.create("table"):addClass("wikitable sortable mw-collapsible"):done() | ||
local header1 = mw.html.create("tr") | local header1 = mw.html.create("tr") | ||
header1:tag("th"):attr("colspan", (level_count + 3)):wikitext("Base " .. name .. " based on PI"):done() | header1:tag("th"):attr("colspan", (level_count + 3)):wikitext("Base " .. name .. " based on PI"):done() | ||
| Line 75: | Line 75: | ||
local filtered_heroes = filtered_heroes() | local filtered_heroes = filtered_heroes() | ||
for _, hero in ipairs(filtered_heroes) do | for _, hero in ipairs(filtered_heroes) do | ||
local base = hero[property] | local base = floor(hero[property] * 100) / 100 | ||
local level = hero["LevelScaling"][property] | local level = floor(hero["LevelScaling"][property] * 100) / 100 | ||
local shots = hero["BulletsPerShot"] | local shots = hero["BulletsPerShot"] | ||
local burst = hero["BulletsPerBurst"] | local burst = hero["BulletsPerBurst"] | ||
Revision as of 19:55, 15 May 2025
Documentation for this module may be created at Module:Sandbox/One Bar/doc
local p = {};
local item_data = mw.loadJsonData("Data:ItemData.json")
local heroes_data = mw.loadJsonData("Data:HeroData.json")
local soul_unlocks_data = mw.loadJsonData("Data:SoulUnlockData.json")
local function souls(frame, item)
return frame:expandTemplate{ title = "Souls", args = {item}}
end
local function hero_icon(frame, hero)
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
return filtered
end
local function get_pi_list()
local soul_pis = {}
for _, v in ipairs(soul_unlocks_data) do
if (v["PowerIncrease"]) then
table.insert(soul_pis, v["RequiredSouls"])
end
end
return soul_pis
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 name = key_to_name[property]
local suffix = property == "BulletDamage" and " (Full Shot)" or ""
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
createTable:node(createTableHeader)
local filtered_heroes = filtered_heroes()
for _, hero in ipairs(filtered_heroes) do
local base = floor(hero[property] * 100) / 100
local level = 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()
: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
return tostring(createTable)
end
local function get_disabled_items_array()
local disabledItems = {}
for k, v in pairs(item_data) do
if (v["IsDisabled"] == true and v["Name"] ~= nil) then
disabledItems[k] = v
end
end
return disabledItems
end
p.disabledItemsTable = function(frame)
local requirements = {}
local listofItems = ""
local filteredData = {}
filteredData = get_disabled_items_array()
local createTable = mw.html.create('table')
:addClass('wikitable sortable')
:tag('caption'):wikitext("List of items"):done()
local createTableHeader = mw.html.create('tr')
createTableHeader
:tag('th'):wikitext('Variable'):done()
:tag('th'):wikitext('Name'):done()
:tag('th'):wikitext('Category'):done()
:tag('th'):wikitext('Description'):done()
createTable:node(createTableHeader)
-- query all the filtered items. itemName is the item table.
for internalName, itemName in pairs(filteredData) do
local display = itemName["Name"]
listofItems = listofItems .. itemName["Name"] .. "<br/>"
local categoryDisplay = itemName["Slot"]
local description = itemName["Description"]
local tableData = mw.html.create('tr')
tableData
:tag('td'):wikitext(internalName):done()
:tag('td'):wikitext(display):done()
:tag('td'):wikitext(categoryDisplay):done()
:tag('td'):wikitext(description):done()
table.insert(requirements, tableData)
end
for _, row in ipairs(requirements) do
createTable:node(row)
end
return tostring(createTable)
end
return p