|
|
| Line 1: |
Line 1: |
| -- TEMPORARY probe. Dumps every SpiritScaling entry in Data:HeroData.json, | | -- TEMPORARY probe: check which localization keys exist for table headers. |
| -- together with the label resolution paths available for each stat key.
| | -- {{#invoke:Sandbox/Vergir|headers}} |
| -- {{#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 lang_module = require('Module:Lang') |
| local dictionary_module = require('Module:Dictionary') | | local dictionary_module = require('Module:Dictionary') |
| local hero_data_module = require('Module:HeroData')
| |
|
| |
|
| -- next() ignores metamethods, and mw.loadJsonData tables are proxies, so
| | local LANG_KEYS = { |
| -- emptiness has to be tested through pairs().
| | 'Hero', 'hero', 'Scaling', 'Stat', 'Stats', |
| local function sorted_keys(tbl)
| | 'StatDesc_Hero', 'citadel_hero', 'Citadel_Hero', |
| local keys = {}
| | 'StatCategory_Weapon', 'StatDesc_Scaling', 'SpiritScaling', |
| if tbl == nil then return keys end | | 'StatDesc_TechPower', 'TechPower_label', |
| for key in pairs(tbl) do table.insert(keys, key) end | | } |
| table.sort(keys) | |
| return keys | |
| end
| |
|
| |
|
| local function attr_label_key(stat) | | local DICT_KEYS = { 'Hero', 'Heroes', 'Stat', 'Stats', 'Scaling', 'Spirit Power' } |
| 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) | | function p.headers(frame) |
| local out = {} | | local out = {'Module:Lang lookups:'} |
| local stats_seen = {}
| | for _, key in ipairs(LANG_KEYS) do |
| | | table.insert(out, '* <code>' .. key .. '</code> → "' .. |
| for _, hero_key in ipairs(sorted_keys(heroes_data)) do | | tostring(lang_module.get_string(key)) .. '"') |
| local hero_data = heroes_data[hero_key] | |
| local stat_keys = sorted_keys(hero_data["SpiritScaling"])
| |
| if #stat_keys > 0 then
| |
| local parts = {}
| |
| for _, stat in ipairs(stat_keys) do
| |
| stats_seen[stat] = true
| |
| 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
| |
| end | | end |
|
| |
| table.insert(out, '') | | table.insert(out, '') |
| table.insert(out, 'Label resolution per stat:') | | table.insert(out, 'Module:Dictionary lookups:') |
| for _, stat in ipairs(sorted_keys(stats_seen)) do | | for _, key in ipairs(DICT_KEYS) do |
| local label_key, postfix_key = attr_label_key(stat)
| | table.insert(out, '* <code>' .. key .. '</code> → "' .. |
| local lang_str = label_key and lang_module.get_string(label_key) or ''
| | tostring(dictionary_module.translate(key)) .. '"') |
| 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 | | end |
| | | table.insert(out, '') |
| | table.insert(out, 'search_string("Hero") → "' .. |
| | tostring(lang_module._search_string('Hero')) .. '"') |
| return table.concat(out, '\n') | | return table.concat(out, '\n') |
| end | | end |
|
| |
|
| return p | | return p |