Editing Module:Sandbox/One Bar

Warning: You are not logged in. Once you make an edit, a temporary account will be created for you. Learn more. Log in or create an account to continue receiving notifications after this account expires, and to access other features.
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 ability_data = mw.loadJsonData("Data:AbilityCards.json")
local soul_unlocks_data = mw.loadJsonData("Data:SoulUnlockData.json")


local function format_spirit_scale(frame, key, base, scale)
local function souls(frame, item)
local spirit_scale = frame:expandTemplate{ title = "ss", args = {(scale or 0)}}
return frame:expandTemplate{ title = "Souls", args = {item}}
return key ..": ".. (base or 0) .. "+" .. spirit_scale .. "\n"
end
end


local function get_stats_spirit_scaling(frame, hero)
local function hero_icon(frame, hero)
local spirit_scaling = hero["SpiritScaling"]
return frame:expandTemplate{ title = "HeroIcon", args = {hero}}
stats_text = ""
end
if (spirit_scaling ~= nil) then
 
for k, v in pairs(spirit_scaling) do
local key_to_name = {
stats_text = stats_text .. format_spirit_scale(frame, k, hero[k], v)
BulletDamage = "Bullet Damage",
MaxHealth = "Health",
TechPower = "Spirit Power",
LightMeleeDamage = "Light Melee Damage",
HeavyMeleeDamage = "Heavy Melee Damage"
}
 
local function filtered_heroes()
local filtered = {}
for _, hero in ipairs(heroes_data) do
local is_disabled = hero["IsDisabled"]
if (is_disabled == "false") then
table.insert(filtered, hero)
end
end
else
stats_text = "-"
end
end
return stats_text
return filtered
end
end


local function get_abilities_spirit_scaling(frame, hero_key, hero)
local function get_pi_list()
local ret = {}
local soul_pis = {}
for i=1,4 do
for _, v in ipairs(soul_unlocks_data) do
local ability = ability_data[hero_key][i]
if (v["PowerIncrease"]) then
local ability_text = ""
table.insert(soul_pis, v["RequiredSouls"])
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
end
if (ability_text == "") then
ability_text = "-"
end
ret[i*2] = ability_text
end
end
return ret
return soul_pis
end
end


-- Outputs a wikitable of heroes and their stats' and abilities' spirit scaling
p.pi_table = function(frame)
-- @function  p.write_spirit_scaling_table
local pi_souls_list = get_pi_list()
-- @param      {}
local level_count = 0
-- @return    {string}
for _ in ipairs(pi_souls_list) do level_count = level_count + 1 end
p.write_spirit_scaling_table = function(frame)
local property = frame.args[1] --frame:getParent().args[1]
local filtered_heroes = {}
local name = key_to_name[property]
local hero_keys = {}
local suffix = property == "BulletDamage" and " (Full Shot)" or ""
for hero_key, hero in pairs(heroes_data) do
if (not hero["IsDisabled"] and not hero["InDevelopment"]) then
local createTable = mw.html.create("table"):addClass("wikitable sortable"):done()
local hero_data = {["hero"] = hero; ["hero_key"] = hero_key}
local header1 = mw.html.create("tr")
table.insert(filtered_heroes, hero_data)
header1:tag("th"):attr("colspan", (level_count + 3)):wikitext("Base " .. name .. " based on PI"):done()
end
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 / 1000)
createTableHeader:tag("th"):wikitext(souls(frame, souls_formatted)):done()
end
end
table.sort(filtered_heroes, function(a, b) return a.hero.Name:lower() < b.hero.Name:lower() end)
createTable:node(createTableHeader)
local create_table = mw.html.create("table"):addClass("wikitable sortable"):done()
local header = mw.html.create("tr")
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)
for _, hero_data in ipairs(filtered_heroes) do
local filtered_heroes = filtered_heroes()
local hero = hero_data.hero
mw.logObject(filtered_heroes)
local hero_key = hero_data.hero_key
for _, hero in ipairs(filtered_heroes) do
local hero_row = mw.html.create("tr")
local base = hero[property]
local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}}
local level = hero["LevelScaling"][property]
hero_row:tag('td'):wikitext(hero_icon):done()
local shots = hero["BulletsPerShot"]
local abilities = get_abilities_spirit_scaling(frame, hero_key, hero)
local tableData = mw.html.create("tr")
for i=1,8 do
tableData
hero_row:tag('td'):wikitext(abilities[i]):done()
:tag("td"):wikitext(hero_icon(hero["Name"])):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
end
create_table:node(hero_row)
createTable:node(tableData)
end
end
return tostring(create_table)
return tostring(createTable)
end
end


Please note that all contributions to The Deadlock Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see Deadlock:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template

Page included on this page: