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 harness: summarises Module:ArcaneSurge output for verification.
local p = {}
local p = {}
local GameData = require("Module:GameData")
-- A stand-in frame whose expandTemplate returns the bare argument, so the
-- module's output stays plain text instead of parser strip markers.
local stub = {
    expandTemplate = function(self, args) return args.args[1] end,
}
function p.check(frame)
    local out = require("Module:ArcaneSurge").render(stub)
    local heroes, abilities, notes = 0, 0, 0
    local lines = {}
    for item in out:gmatch("<li>(.-)</li>") do
        heroes = heroes + 1
        for _ in item:gmatch("%(after T") do notes = notes + 1 end
        local _, commas = item:gsub(", ", "")
        abilities = abilities + commas + 1
        table.insert(lines, item)
    end
    return "<pre>heroes=" .. heroes .. " abilities=" .. abilities
        .. " notes=" .. notes .. "\n\n"
        .. mw.text.encode(table.concat(lines, "\n")) .. "</pre>"
end
-- Dumps every Scale block of a named ability, to compare live data against
-- local expectations.
function p.scales(frame)
    local name = frame.args[1]
    local data = mw.loadJsonData(GameData.Dataset.ABILITIES)
    for key, record in pairs(data) do
        if record["Name"] == name then
            local rows = { "key = " .. key }
            local function walk(node, path)
                if type(node) ~= "table" then return end
                for k, v in pairs(node) do
                    if type(v) == "table" then
                        local scale = v["Scale"]
                        if type(scale) == "table" and scale["Type"] then
                            table.insert(rows, path .. tostring(k)
                                .. ": Value=" .. tostring(v["Value"])
                                .. " Scale.Type=" .. tostring(scale["Type"])
                                .. " Scale.Value=" .. tostring(scale["Value"]))
                        end
                        walk(v, path .. tostring(k) .. ".")
                    end
                end
            end
            walk(record, "")
            return "<pre>" .. mw.text.encode(table.concat(rows, "\n")) .. "</pre>"
        end
    end
    return "not found: " .. tostring(name)
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: