Module:AbilityTable/ComplexRenderers: Difference between revisions

Jump to navigation Jump to search
Vergir (talk | contribs)
rename val_stat_cells to render_upgradable_stat, simplify RenderHealReduce to use it, fix Lists.props to Lists.lists (with help from vergir-bot LLM)
Vergir (talk | contribs)
update renderer comments, remove unused GameData require, extract find_base_melee_scale to module level (with help from vergir-bot LLM)
Line 1: Line 1:
-- Complex cell renderers for AbilityTable.
-- Complex cell renderers for AbilityTable.
local Lists   = require("Module:AbilityTable/Lists")
local Lists = require("Module:AbilityTable/Lists")
local GameData = require("Module:GameData")


-- ============================================================
-- ============================================================
Line 66: Line 65:
     end
     end
     return false
     return false
end
-- Finds the base-level melee scale value by scanning for Scale.Type == "melee".
local function find_base_melee_scale(ability)
    for _, v in pairs(ability) do
        if type(v) == "table" then
            local scale = v["Scale"]
            if type(scale) == "table"
                and scale["Type"] == "melee"
                and type(scale["Value"]) == "number"
                and scale["Value"] > 0
            then
                return scale["Value"]
            end
        end
    end
    return nil
end
end


Line 154: Line 170:
local p = {}
local p = {}


-- Charges: shows base charges, time between charges, and upgrade notes.
-- Renders charge count and time between charges.
-- Special case for abilities that gain charges only through upgrades.
function p.RenderCharges(ability)
function p.RenderCharges(ability)
     local base_charges  = unwrap_value(ability["AbilityCharges"])
     local base_charges  = unwrap_value(ability["AbilityCharges"])
Line 206: Line 223:
end
end


-- Melee: shows light melee scaling and upgrade notes.
-- Renders light melee scaling.
-- Special case for upgrades that change to heavy melee scaling.
function p.RenderMelee(ability)
function p.RenderMelee(ability)
    local function find_base_melee_scale(ability)
        for _, v in pairs(ability) do
            if type(v) == "table" then
                local scale = v["Scale"]
                if type(scale) == "table"
                    and scale["Type"] == "melee"
                    and type(scale["Value"]) == "number"
                    and scale["Value"] > 0
                then
                    return scale["Value"]
                end
            end
        end
        return nil
    end
     local cells = {}
     local cells = {}
     local base_scale = find_base_melee_scale(ability)
     local base_scale = find_base_melee_scale(ability)
Line 256: Line 258:
end
end


-- HealReduce: shows heal reduction percentage and upgrade notes.
-- Renders heal reduction percentage.
-- Special case for DisableHealing, shown as 100%.
function p.RenderHealReduce(ability)
function p.RenderHealReduce(ability)
     -- DisableHealing is always 100%, handle it separately
     -- DisableHealing is always 100%, handle it separately
Line 276: Line 279:
end
end


-- Debuff: shared by debuffresist and dispelmagic.
-- Shows a note if an ability acquires a debuff via upgrades.
-- Outputs upgrade-tier notes for debuffs added only in upgrades (not at base).
-- Shared by debuffresist and dispelmagic.
function p.RenderDebuff(ability, stat)
function p.RenderDebuff(ability, stat)
     local stat_props = Lists.lists[stat]
     local stat_props = Lists.lists[stat]
Line 334: Line 337:
end
end


-- MoveSlow: shows move slow percentage and caster slow note if present.
-- Renders move slow percentage.
-- Appends a note if the ability also self-slows the caster.
function p.RenderMoveSlow(ability)
function p.RenderMoveSlow(ability)
     local cells = render_upgradable_stat(ability, "Move Slow", Lists.lists["moveslow"], "%")
     local cells = render_upgradable_stat(ability, "Move Slow", Lists.lists["moveslow"], "%")
Line 347: Line 351:
end
end


-- DashSlow: shows dash slow percentage, auto-detects caster self-slow.
-- Renders dash slow percentage.
-- Special case for GroundDashReductionPercent coexisting with another dashslow
-- prop, which means it's a caster self-slow and is noted separately.
function p.RenderDashSlow(ability)
function p.RenderDashSlow(ability)
     local stat_props = Lists.lists["dashslow"]
     local stat_props = Lists.lists["dashslow"]