Editing Module:Sandbox/Vergir

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 1: Line 1:
-- TEMPORARY probe. Dumps every SpiritScaling entry in Data:HeroData.json,
-- together with the label resolution paths available for each stat key.
-- {{#invoke:Sandbox/Vergir|dump}}
local p = {}
local p = {}
local heroes_data = mw.loadJsonData("Data:HeroData.json")
local attributes_data = mw.loadJsonData("Data:AttributeData.json")
local lang_module = require('Module:Lang')
local dictionary_module = require('Module:Dictionary')
local hero_data_module = require('Module:HeroData')
local function attr_label_key(stat)
for _, category in pairs(attributes_data) do
if category[stat] ~= nil then
return category[stat]["label"], category[stat]["postfix"]
end
end
return nil, nil
end
function p.dump(frame)
local keys = {}
for hero_key, hero_data in pairs(heroes_data) do
local scaling = hero_data["SpiritScaling"]
if scaling ~= nil and next(scaling) ~= nil then
table.insert(keys, hero_key)
end
end
table.sort(keys)
local out = {}
local stats_seen = {}
for _, hero_key in ipairs(keys) do
local hero_data = heroes_data[hero_key]
local stat_keys = {}
for stat in pairs(hero_data["SpiritScaling"]) do
table.insert(stat_keys, stat)
stats_seen[stat] = true
end
table.sort(stat_keys)
local parts = {}
for _, stat in ipairs(stat_keys) do
local base = hero_data_module.get_stat(hero_data, stat)
table.insert(parts, stat .. '=' .. tostring(hero_data["SpiritScaling"][stat]) ..
' (base ' .. tostring(base) .. ')')
end
table.insert(out, '* <code>' .. hero_key .. '</code> ' .. tostring(hero_data["Name"]) ..
' [dev=' .. tostring(hero_data["InDevelopment"]) ..
' disabled=' .. tostring(hero_data["IsDisabled"]) ..
' labs=' .. tostring(hero_data["InHeroLabs"]) ..
' selectable=' .. tostring(hero_data["IsSelectable"]) .. ']: ' ..
table.concat(parts, ', '))
end
local stat_list = {}
for stat in pairs(stats_seen) do table.insert(stat_list, stat) end
table.sort(stat_list)
table.insert(out, '')
table.insert(out, 'Label resolution per stat:')
for _, stat in ipairs(stat_list) do
local label_key, postfix_key = attr_label_key(stat)
local lang_str = label_key and lang_module.get_string(label_key) or ''
local postfix_str = postfix_key and lang_module.get_string(postfix_key) or ''
local dict_str = dictionary_module.translate(stat)
table.insert(out, '* <code>' .. stat .. '</code> attr_label=<code>' ..
tostring(label_key) .. '</code> lang="' .. tostring(lang_str) ..
'" postfix="' .. tostring(postfix_str) ..
'" dict="' .. tostring(dict_str) .. '"')
end
return table.concat(out, '\n')
end
return p
return p
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: