Module:Sandbox/One BarGive feedback
Jump to navigation
Jump to search
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 ability_data = mw.loadJsonData("Data:AbilityCards.json")
p.write_multishot_stats = function(frame)
local burst_heroes = {}
local spreadshot_heroes = {}
for _, hero in pairs(heroes_data) do
if (hero["BulletsPerShot"] > 1 and not hero["IsDisabled"]) then
table.insert(spreadshot_heroes, hero)
elseif (hero["BulletsPerBurst"] > 1 and not hero["IsDisabled"]) then
table.insert(burst_heroes, hero)
end
end
local multishot_str = "Weapons with multiple projectiles (Spreadshot):\n"
for _, hero in ipairs(spreadshot_heroes) do
local base = math.floor(hero["BulletDamage"] * 100) / 100
local level = math.floor(hero["LevelScaling"]["BulletDamage"] * 100) / 100
local shots = hero["BulletsPerShot"]
local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}}
local stat_str = "* " .. hero_icon .. ": " .. shots .. " pellets, "
.. base .. "/pellet, +" .. level .. "/pellet\n"
multishot_str = multishot_str .. stat_str
end
multishot_str = multishot_str .. "Weapons with burst fire (Burst Fire):\n"
for _, hero in ipairs(burst_heroes) do
local base = math.floor(hero["BulletDamage"] * 100) / 100
local level = math.floor(hero["LevelScaling"]["BulletDamage"] * 100) / 100
local shots = hero["BulletsPerBurst"]
local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}}
local stat_str = "* " .. hero_icon .. ": " .. shots .. " rounds, "
.. base .. "/bullet, +" .. level .. "/bullet\n"
multishot_str = multishot_str .. stat_str
end
return multishot_str
end
p.write_spirit_scaling_table = function(frame)
local filtered_heroes = {}
for hero_key, hero in pairs(heroes_data) do
if (not hero["IsDisabled"]) then
filtered_heroes[hero_key] = hero
end
end
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"):wikitext("Stats"):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_key, hero in pairs(filtered_heroes) do
local spirit_scaling = hero["SpiritScaling"]
local hero_row = mw.html.create("tr")
stats_text = ""
if (spirit_scaling ~= nil and next(spirit_scaling) ~= nil) then
for k, v in ipairs(spirit_scaling) do
stats_text = stats_text .. k ..": ".. hero[k] .. "+" .. v .. "\n"
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
if (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
create_table:node(hero_row)
end
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
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