Module:AbilityTable/ComplexRenderers: Difference between revisions

Jump to navigation Jump to search
Vergir (talk | contribs)
RenderBarrier: use the compact {{Ss}} form and keep one decimal on scaling totals (with help from vergir-bot LLM)
add scalingspirit
 
Line 399: Line 399:
             end
             end
         end
         end
    end
    return cells
end
-- Renders Spirit Power scaling.
-- Shows the Scale.Value for abilities whose Scale.Type is "spirit".
function p.RenderSpiritScaling(ability)
    local base_scale = nil
    local base_prop = nil
    -- Find base Spirit scaling
    for k, v in pairs(ability) do
        if k ~= "Upgrades" and type(v) == "table" then
            local scale = v["Scale"]
            if type(scale) == "table"
              and scale["Type"] == "spirit"
              and type(scale["Value"]) == "number"
              and scale["Value"] ~= 0 then
                base_scale = scale["Value"]
                base_prop = k
                break
            end
        end
    end
    local cells = {}
    if base_scale then
        cells["Spirit Scaling"] = "×" .. base_scale
    end
    local upgrades = ability["Upgrades"]
    if type(upgrades) ~= "table" then return cells end
    local notes = {}
    for i, tier in ipairs(upgrades) do
        if type(tier) == "table" then
            local upgrade_scale = nil
            for k, v in pairs(tier) do
                if type(v) == "table" then
                    local scale = v["Scale"]
                    if type(scale) == "table"
                      and scale["Type"] == "spirit"
                      and type(scale["Value"]) == "number"
                      and scale["Value"] ~= 0 then
                        upgrade_scale = scale["Value"]
                        break
                    end
                end
            end
            if upgrade_scale then
                table.insert(notes,
                    "on T" .. i .. " gets +×" .. upgrade_scale .. " Spirit scaling")
            end
        end
    end
    if #notes > 0 then
        cells["Notes"] = table.concat(notes, ". ")
     end
     end