Module:AbilityTable/ComplexRenderers: Difference between revisions

Jump to navigation Jump to search
Vergir (talk | contribs)
m typo
Vergir (talk | contribs)
m delete duplicate function
Line 364: Line 364:
                         cells["Heavy Melee Scaling"] = "×" .. scale["Value"]
                         cells["Heavy Melee Scaling"] = "×" .. scale["Value"]
                         cells["Notes"] = "Only becomes Heavy Melee on '''T" .. i .. "''' upgrade"
                         cells["Notes"] = "Only becomes Heavy Melee on '''T" .. i .. "''' upgrade"
                        return cells
                    end
                end
            end
        end
    end
    return cells
end
-- Renders base damage and heavy melee scaling.
-- Notes when heavy melee is only available via upgrade.
function p.RenderHeavyMelee(ability)
    -- Find base heavy_melee property
    local base_damage, base_scale
    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"] == "heavy_melee"
              and type(scale["Value"]) == "number" then
                base_damage = v["Value"] or 0
                base_scale = scale["Value"]
                break
            end
        end
    end
    local cells = {}
    -- Active at base
    if base_scale and base_scale > 0 then
        cells["Base Damage"] = tostring(base_damage)
        cells["Heavy Melee Scaling"] = "×" .. base_scale
        return cells
    end
    -- Not at base — find in upgrades
    local upgrades = ability["Upgrades"]
    if type(upgrades) ~= "table" then return cells end
    for i, tier in ipairs(upgrades) do
        if type(tier) == "table" then
            for k, v in pairs(tier) do
                if type(v) == "table" then
                    local scale = v["Scale"]
                    if type(scale) == "table" and scale["Type"] == "heavy_melee"
                      and type(scale["Value"]) == "number" and scale["Value"] > 0 then
                        cells["Base Damage"] = tostring(v["Value"] or 0)
                        cells["Heavy Melee Scaling"] = "×" .. scale["Value"]
                        cells["Notes"] = "Only becomes '''Heavy Melee''' on T" .. i .. " upgrade"
                         return cells
                         return cells
                     end
                     end