| 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_json_item(name) |
| local spirit_scale = frame:expandTemplate{ title = "ss", args = {(scale or 0)}}
| | for _, v in pairs(data) do |
| return key ..": ".. (base or 0) .. "+" .. spirit_scale .. "\n"
| | if (v["Name"] == name) then |
| end
| | return v |
| | |
| local function get_stats_spirit_scaling(frame, hero)
| |
| local spirit_scaling = hero["SpiritScaling"] | |
| 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 | | end |
| if (ability_text == "") then
| |
| ability_text = "-"
| |
| end
| |
| ret[i*2] = ability_text
| |
| end | | end |
| return ret | | return nil |
| end | | end |
|
| |
|
| -- Outputs a wikitable of heroes and their stats' and abilities' spirit scaling
| | local function get_cost(item_name) |
| -- @function p.write_spirit_scaling_table
| | local item = get_json_item(item_name) |
| -- @param {}
| | if(item == nil) then return "<span style=\"color:red;\">Item Not Found.</span>" end |
| -- @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 | | return cur_item["Cost"] |
| 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
| |
| create_table:node(hero_row)
| |
| end
| |
|
| |
| return tostring(create_table)
| |
| end | | end |
|
| |
|
| local function get_disabled_items_array()
| | p.get_cost = function(frame) |
| local disabledItems = {} | | local item_name = frame.args[1] |
| for k, v in pairs(item_data) do | | return Format(get_cost(item_name)) |
| if (v["IsDisabled"] == true and v["Name"] ~= nil) then
| |
| disabledItems[k] = v
| |
| end
| |
| end
| |
| return disabledItems
| |
| end | | end |
|
| |
|
| p.disabledItemsTable = function(frame) | | -- Module access point |
| local requirements = {} | | function p._get_cost(a) |
| local listofItems = ""
| | a = tostring(a) or '0' |
| local filteredData = {}
| | return get_cost(a) |
| 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 | | end |
|
| |
|
| return p | | return p |