Module:Sandbox/Monster Domosed/AbilityTable/ComplexRenderers: Difference between revisions

Undo
Tag: Undo
No edit summary
Line 413: Line 413:
function p.RenderSpiritScaling(ability)
function p.RenderSpiritScaling(ability)
     local props = {}
     local props = {}
    -- Build a Key -> display Name lookup for the prop names. The flattened
    -- top-level prop only keeps { Value, Scale }, while the human-readable
    -- Name lives alongside the Key in the nested Info1/Info2 entries, so scan
    -- the whole record for any entry pairing a string Key with a string Name.
    local names, seen = {}, {}
    local function walk(node)
        if type(node) ~= "table" or seen[node] then return end
        seen[node] = true
        local k, n = node["Key"], node["Name"]
        if type(k) == "string" and type(n) == "string" then names[k] = n end
        for _, v in pairs(node) do
            if type(v) == "table" then walk(v) end
        end
    end
    walk(ability)


     -- Gather every base Spirit-scaling instance (skip the Upgrades table).
     -- Gather every base Spirit-scaling instance (skip the Upgrades table).
Line 422: Line 438:
               and type(scale["Value"]) == "number"
               and type(scale["Value"]) == "number"
               and scale["Value"] ~= 0 then
               and scale["Value"] ~= 0 then
                 local label = type(v["Name"]) == "string" and v["Name"] or k
                -- Prefer a Name carried directly on the prop, then a name
                -- recovered from the nested Key/Name entries, else the key.
                 local label = type(v["Name"]) == "string" and v["Name"]
                              or names[k] or k
                 table.insert(props, { key = k, value = scale["Value"], name = label })
                 table.insert(props, { key = k, value = scale["Value"], name = label })
             end
             end