Editing Module:Sandbox/One Bar

Jump to navigation Jump to search
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 4: Line 4:
local ability_data = mw.loadJsonData("Data:AbilityCards.json")
local ability_data = mw.loadJsonData("Data:AbilityCards.json")


local function format_spirit_scale(frame, key, base, scale)
p.write_multishot_stats = function(frame)
local spirit_scale = frame:expandTemplate{ title = "ss", args = {(scale or 0)}}
local function hero_sort(h1, h2)  
return key ..": ".. (base or 0) .. "+" .. spirit_scale .. "\n"
return h1["Name"] < h2["Name"]
end
end
 
local spreadshot_heroes = {}
local function get_stats_spirit_scaling(frame, hero)
local burst_heroes = {}
local spirit_scaling = hero["SpiritScaling"]
for _, hero in pairs(heroes_data) do
stats_text = ""
if (hero["BulletsPerShot"] > 1 and not hero["IsDisabled"]) then
if (spirit_scaling ~= nil) then
table.insert(spreadshot_heroes, hero)
for k, v in pairs(spirit_scaling) do
elseif (hero["BulletsPerBurst"] > 1 and not hero["IsDisabled"]) then
stats_text = stats_text .. format_spirit_scale(frame, k, hero[k], v)
table.insert(burst_heroes, hero)
end
end
else
stats_text = "-"
end
end
return stats_text
end
table.sort(spreadshot_heroes, hero_sort)
 
table.sort(burst_heroes, hero_sort)
local function get_abilities_spirit_scaling(frame, hero_key, hero)
local ret = {}
local multishot_str = "Weapons with multiple projectiles (Spreadshot):\n"
for i=1,4 do
for _, hero in ipairs(spreadshot_heroes) do
local ability = ability_data[hero_key][i]
local base = math.floor(hero["BulletDamage"] * 100) / 100
local ability_text = ""
local level = math.floor(hero["LevelScaling"]["BulletDamage"] * 100) / 100
if (ability ~= nil) then
local shots = hero["BulletsPerShot"]
ret[i*2-1] = ability["Name"]
local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}}
if (ability["Info1"] ~= nil and ability["Info1"]["Main"] ~= nil
local stat_str = "* " .. hero_icon .. ": " .. shots .. " pellets, "  
and ability["Info1"]["Main"]["Props"] ~= nil) then
.. base .. "/pellet, +" .. level .. "/pellet\n"
for _, prop in ipairs(ability["Info1"]["Main"]["Props"]) do
multishot_str = multishot_str .. stat_str
if (prop["Scale"] ~= nil and prop["Scale"]["Type"] == "spirit" and prop["Scale"]["Value"] ~= 0) then
end
ability_text = ability_text .. format_spirit_scale(frame, prop["Name"], prop["Value"], prop["Scale"]["Value"])
end
multishot_str = multishot_str .. "Weapons with burst fire (Burst Fire):\n"
end
for _, hero in ipairs(burst_heroes) do
end
local base = math.floor(hero["BulletDamage"] * 100) / 100
else
local level = math.floor(hero["LevelScaling"]["BulletDamage"] * 100) / 100
ret[i*2-1] = "-"
local shots = hero["BulletsPerBurst"]
end
local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}}
if (ability_text == "") then
local stat_str = "* " .. hero_icon .. ": " .. shots .. " rounds, "  
ability_text = "-"
.. base .. "/bullet, +" .. level .. "/bullet\n"
end
multishot_str = multishot_str .. stat_str
ret[i*2] = ability_text
end
end
return ret
return 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"] and not hero["InDevelopment"]) then
if (not hero["IsDisabled"]) then
local hero_data = {["hero"] = hero; ["hero_key"] = hero_key}
filtered_heroes[hero_key] = hero
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 67: Line 58:
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 73: Line 65:
create_table:node(header)
create_table:node(header)
for _, hero_data in ipairs(filtered_heroes) do
for hero_key, hero in pairs(filtered_heroes) do
local hero = hero_data.hero
local spirit_scaling = hero["SpiritScaling"]
local hero_key = hero_data.hero_key
local hero_row = mw.html.create("tr")
local hero_row = mw.html.create("tr")
local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}}
stats_text = ""
hero_row:tag('td'):wikitext(hero_icon):done()
if (spirit_scaling ~= nil and next(spirit_scaling) ~= nil) then
local abilities = get_abilities_spirit_scaling(frame, hero_key, hero)
for k, v in ipairs(spirit_scaling) do
for i=1,8 do
stats_text = stats_text .. k ..": ".. hero[k] .. "+" .. v .. "\n"
hero_row:tag('td'):wikitext(abilities[i]):done()
end
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
-- probably too much nil check but I want the table to print for now
if (ability["Info1"] ~= nil and ability["Info1"]["Main"] ~= nil
and 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)
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: