| 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 get_pi_list() |
| local spirit_scaling = hero["SpiritScaling"] | | local soul_pis = {} |
| stats_text = ""
| | for _, v in ipairs(soul_unlocks_data) do |
| if (spirit_scaling ~= nil) then | | if (v["PowerIncrease"]) then |
| for k, v in pairs(spirit_scaling) do
| | table.insert(soul_pis, v["RequiredSouls"]) |
| stats_text = stats_text .. format_spirit_scale(frame, k, hero[k], v) | |
| end | | end |
| else
| |
| stats_text = "-"
| |
| end | | end |
| return stats_text | | return soul_pis |
| end | | end |
|
| |
|
| local function get_abilities_spirit_scaling(frame, hero_key, hero)
| | p.pi_table = function(frame) |
| local ret = {} | | local pi_souls_list = get_pi_list() |
| for i=1,4 do | | local property = frame:getParent().args[1] |
| local ability = ability_data[hero_key][i]
| | |
| local ability_text = ""
| | local createTable = mw.html.create('table'):addClass('wikitable sortable'):done() |
| if (ability ~= nil) then | | |
| ret[i*2-1] = ability["Name"]
| | local createTableHeader = mw.html.create('tr') |
| if (ability["Info1"] ~= nil and ability["Info1"]["Main"] ~= nil
| | createTableHeader |
| and ability["Info1"]["Main"]["Props"] ~= nil) then
| | :tag('th'):wikitext('Hero'):done() |
| for _, prop in ipairs(ability["Info1"]["Main"]["Props"]) do
| | :tag('th'):wikitext('Base'):done() |
| if (prop["Scale"] ~= nil and prop["Scale"]["Type"] == "spirit" and prop["Scale"]["Value"] ~= 0) then
| | :tag('th'):wikitext('PL Increase'):done() |
| ability_text = ability_text .. format_spirit_scale(frame, prop["Name"], prop["Value"], prop["Scale"]["Value"])
| | for _, v in ipairs(pi_souls_list) do |
| end
| | createTableHeader:tag('th'):wikitext(souls(frame, v)):done() |
| end
| |
| end
| |
| else
| |
| ret[i*2-1] = "-"
| |
| end
| |
| if (ability_text == "") then
| |
| ability_text = "-"
| |
| end
| |
| ret[i*2] = ability_text
| |
| end | | end |
| return ret | | createTable:node(createTableHeader) |
| 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()
| |
| 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 | | for _, hero in pairs(heroes_data) do |
| local hero = hero_data.hero | | local base = hero[property] |
| local hero_key = hero_data.hero_key | | local shots = hero["BulletsPerShot"] |
| local hero_row = mw.html.create("tr") | | local level = hero["LevelScaling"][property] |
| local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}} | | local tableData = mw.html.create('tr') |
| hero_row:tag('td'):wikitext(hero_icon):done()
| | tableData |
| local abilities = get_abilities_spirit_scaling(frame, hero_key, hero)
| | :tag('td'):wikitext(hero["Name"]):done() |
| for i=1,8 do | | :tag('td'):wikitext(base):done() |
| hero_row:tag('td'):wikitext(abilities[i]):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 |
|
| |
|