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 1: Line 1:
local p = {};
local p = {};
local item_data = mw.loadJsonData("Data:ItemData.json")
local data = mw.loadJsonData("Data:ItemData.json")
local heroes_data = mw.loadJsonData("Data:HeroData.json")
local ability_data = mw.loadJsonData("Data:AbilityCards.json")


local function format_spirit_scale(frame, key, base, scale)
local function get_disabled_items_array()
local spirit_scale = frame:expandTemplate{ title = "ss", args = {(scale or 0)}}
local similarItems = {}
return key ..": ".. (base or 0) .. "+" .. spirit_scale .. "\n"
local hash = {}
end
local noDuplicates = {}
 
for _, v in pairs(data) do
local function get_stats_spirit_scaling(frame, hero)
if (v["IsDisabled"] == true and v["Name"] ~= nil) then
local spirit_scaling = hero["SpiritScaling"]
table.insert(similarItems, v)
stats_text = ""
if (spirit_scaling ~= nil) then
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
 
local function get_abilities_spirit_scaling(frame, hero_key, hero)
local ret = {}
for i=1,4 do
local ability = ability_data[hero_key][i]
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
return ret
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 hero_keys = {}
for hero_key, hero in pairs(heroes_data) do
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
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()
-- remove duplicate items if that item contains multiple keys of the same stat increase (eg. Fleetfoot has both "BonusMoveSpeed", "ActiveBonusMoveSpeed" in move speed).
local header = mw.html.create("tr")
-- there might be a more efficient way to prevent adding duplicate items in the first place in the above for loop
header
for _, v in pairs(similarItems) do
:tag("th"):wikitext("Hero"):done()
if (not hash[v]) then
:tag("th"):attr("colspan", 2):wikitext("First Skill"):done()
noDuplicates[#noDuplicates+1] = v
:tag("th"):attr("colspan", 2):wikitext("Second Skill"):done()
hash[v] = true
: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 hero = hero_data.hero
local hero_key = hero_data.hero_key
local hero_row = mw.html.create("tr")
local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}}
hero_row:tag('td'):wikitext(hero_icon):done()
local abilities = get_abilities_spirit_scaling(frame, hero_key, hero)
for i=1,8 do
hero_row:tag('td'):wikitext(abilities[i]):done()
end
end
create_table:node(hero_row)
end
end
return noDuplicates
return tostring(create_table)
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
end


Line 111: Line 35:
local createTableHeader = mw.html.create('tr')
local createTableHeader = mw.html.create('tr')
createTableHeader
createTableHeader
:tag('th'):wikitext('Variable'):done()
:tag('th'):wikitext('Name'):done()
:tag('th'):wikitext('Name'):done()
:tag('th'):wikitext('Category'):done()
:tag('th'):wikitext('Category'):done()
Line 119: Line 42:
-- query all the filtered items. itemName is the item table.
-- query all the filtered items. itemName is the item table.
for internalName, itemName in pairs(filteredData) do  
for internalName, itemName in ipairs(filteredData) do  
local display = itemName["Name"]
local display = frame:expandTemplate{
title = 'ItemIcon',
args = {
itemName["Name"]
}
}
listofItems = listofItems .. itemName["Name"] .. "<br/>"
listofItems = listofItems .. itemName["Name"] .. "<br/>"
-- Get category display using ItemType template with appropriate parameters
local categoryDisplay = itemName["Slot"]
local categoryDisplay
if itemName["Slot"] == "Armor" then
categoryDisplay = frame:expandTemplate{
title = 'ItemType',
args = { "Armor", "Vitality" }
}
elseif itemName["Slot"] == "Tech" then
categoryDisplay = frame:expandTemplate{
title = 'ItemType',
args = { "Tech", "Spirit" }
}
else -- Weapon
categoryDisplay = frame:expandTemplate{
title = 'ItemType',
args = { "Weapon", "Weapon" }
}
end
local description = itemName["Description"]
local description = itemName["Description"]
Line 131: Line 75:
local tableData = mw.html.create('tr')
local tableData = mw.html.create('tr')
tableData
tableData
:tag('td'):wikitext(internalName):done()
:tag('td'):wikitext(display):done()
:tag('td'):wikitext(display):done()
:tag('td'):wikitext(categoryDisplay):done()
:tag('td'):wikitext(categoryDisplay):done()
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: