Module:AbilityTable/ComplexRenderers: Difference between revisions

Vergir (talk | contribs)
m knockback => displacement
Vergir (talk | contribs)
simplify RenderDebuff to just find earliest upgrade tier, remove debuff_short_name table (with help from vergir-bot LLM)
Line 86: Line 86:
     return nil
     return nil
end
end
-- ============================================================
-- Debuff short names (used by RenderDebuff)
-- ============================================================
local debuff_short_name = {
    ["StunDuration"]              = "stun",
    ["SleepDuration"]              = "sleep",
    ["SilenceDuration"]            = "silence",
    ["SilenceDebuff"]              = "silence",
    ["PetrifyDuration"]            = "petrify",
    ["HexDuration"]                = "hex",
    ["ImmobilizeDuration"]        = "immobilize",
    ["LiftDuration"]              = "lift",
    ["HoldInPlaceDuration"]        = "immobilize",
    ["RestrictionDuration"]        = "immobilize",
    ["SlowPercent"]                = "slow",
    ["EnemySlowPct"]              = "slow",
    ["MoveSlowPercent"]            = "slow",
    ["GroundDashReductionPercent"] = "dash slow",
    ["SlowDuration"]              = "slow",
    ["MaxSlowDuration"]            = "slow",
    ["BulletDamageAmpDuration"]    = "bullet amp",
    ["BulletResistReduction"]      = "bullet resist reduction",
    ["TimeSlowDuration"]          = "time slow",
    ["LateCheckoutStun"]          = "stun",
    ["BurnDuration"]              = "burn",
    ["BleedDuration"]              = "bleed",
    ["VenomDuration"]              = "venom",
    ["TossDuration"]              = "displacement",
}


-- ============================================================
-- ============================================================
Line 398: Line 367:
end
end


-- Shows a note if an ability acquires a debuff via upgrades.
-- Shows a note if an ability only acquires a dispellable debuff via upgrades.
-- Shared by debuffresist and dispelmagic.
-- Shared by debuffresist and dispelmagic.
function p.RenderDebuff(ability, stat)
function p.RenderDebuff(ability, stat)
Line 411: Line 380:
     end
     end


    -- Find the earliest upgrade tier with a matching prop.
     local upgrades = ability["Upgrades"]
     local upgrades = ability["Upgrades"]
     if type(upgrades) ~= "table" then return cells end
     if type(upgrades) ~= "table" then return cells end
    local tier_debuffs = {}
    local seen_names  = {}


     for i, tier in ipairs(upgrades) do
     for i, tier in ipairs(upgrades) do
         if type(tier) == "table" then
         if type(tier) == "table" then
            local names_this_tier = {}
            local seen_this_tier  = {}
             for _, prop in ipairs(stat_props) do
             for _, prop in ipairs(stat_props) do
                 local v = tier[prop]
                 local v = tier[prop]
Line 426: Line 391:
                     if type(v) == "table" then v = v["Value"] end
                     if type(v) == "table" then v = v["Value"] end
                     if v ~= nil and v ~= 0 and v ~= "" and v ~= "0" and v ~= "0m" then
                     if v ~= nil and v ~= 0 and v ~= "" and v ~= "0" and v ~= "0m" then
                         local short = debuff_short_name[prop] or "debuff"
                         cells["Notes"] = "After T" .. i
                        if not seen_this_tier[short] then
                         return cells
                            seen_this_tier[short] = true
                            if not seen_names[short] then
                                seen_names[short] = true
                                table.insert(names_this_tier, short)
                            end
                         end
                     end
                     end
                 end
                 end
            end
            if #names_this_tier > 0 then
                tier_debuffs[i] = names_this_tier
             end
             end
         end
         end
     end
     end


    local tier_indices = {}
    for i in pairs(tier_debuffs) do table.insert(tier_indices, i) end
    table.sort(tier_indices)
    local parts = {}
    for _, i in ipairs(tier_indices) do
        table.insert(parts, "T" .. i .. " " .. table.concat(tier_debuffs[i], " + "))
    end
    if #parts > 0 then cells["Notes"] = table.concat(parts, ", ") end
     return cells
     return cells
end
end