Module:Sandbox/Vergir: Difference between revisions

Vergir (talk | contribs)
Temporary verification harness for Module:ArcaneSurge (with help from vergir-bot LLM)
Vergir (talk | contribs)
Improve verification harness: plain-text output and scaling diagnostic (with help from vergir-bot LLM)
Line 1: Line 1:
-- Temporary harness: summarises Module:ArcaneSurge output for verification.
-- Temporary harness: summarises Module:ArcaneSurge output for verification.
local p = {}
local p = {}
local GameData = require("Module:GameData")


function p.check(frame)
function p.check(frame)
     local out = require("Module:ArcaneSurge").render(frame)
     local out = require("Module:ArcaneSurge").render(frame)


     local heroes, abilities, notes = 0, 0, 0
     local lines, heroes, notes = {}, 0, 0
    for _ in out:gmatch("<li>") do heroes = heroes + 1 end
    for _ in out:gmatch("%(after T") do notes = notes + 1 end
 
    local lines = {}
     for item in out:gmatch("<li>(.-)</li>") do
     for item in out:gmatch("<li>(.-)</li>") do
         local hero = item:match('data%-hero%-name="([^"]*)"') or "?"
        heroes = heroes + 1
         local names = {}
         local text = item:gsub("<!%-%-.-%-%->", ""):gsub("<[^>]*>", "")
        for name in item:gmatch('data%-ability%-name="([^"]*)"') do
         text = text:gsub("%s+", " "):gsub("^%s+", ""):gsub("%s+$", "")
            table.insert(names, name)
         for _ in text:gmatch("%(after T") do notes = notes + 1 end
            abilities = abilities + 1
         table.insert(lines, text)
        end
         for name in item:gmatch('data%-ability%-name="([^"]*)"[^\n]-') do end
         table.insert(lines, hero .. " = " .. table.concat(names, ", "))
     end
     end


     -- flag which abilities carry a tier note
     return "<pre>heroes=" .. heroes .. " notes=" .. notes .. "\n\n"
     local flagged = {}
        .. mw.text.encode(table.concat(lines, "\n")) .. "</pre>"
     for item in out:gmatch("<li>(.-)</li>") do
end
        for name, tail in item:gmatch('data%-ability%-name="([^"]*)"(.-)</span></span>') do end
 
    end
-- Dumps every Scale block of a named ability, to compare live data against
    for name in out:gmatch('data%-ability%-name="([^"]*)"[^<]*<span[^>]*>.-</span></span> %(after T%d%)') do
-- local expectations.
        table.insert(flagged, name)
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
     end
 
     return "not found: " .. tostring(name)
     return "<pre>heroes=" .. heroes .. " abilities=" .. abilities .. " notes=" .. notes
        .. "\nnoted: " .. table.concat(flagged, ", ")
        .. "\n\n" .. table.concat(lines, "\n") .. "</pre>"
end
end


return p
return p