Module:AbilityTable/ComplexRenderers: Difference between revisionsGive feedback
RenderCharges: unwrap AbilityCooldownBetweenCharge so the Time Between Charges column keeps working once the property becomes a {Value, Scale} object (with help from vergir-bot LLM) |
Add RenderExtraDebuffResist for the extradebuffresist list (with help from vergir-bot LLM) |
||
| Line 45: | Line 45: | ||
end | end | ||
return nil, nil, nil | return nil, nil, nil | ||
end | |||
-- Returns the first non-zero value among `fields` within a single record layer | |||
-- (the base ability record, or one upgrade tier). Returns nil when none apply. | |||
local function layer_value(layer, fields) | |||
for _, field in ipairs(fields) do | |||
local v = unwrap_value(layer[field]) | |||
if v and v ~= 0 then return math.abs(v) end | |||
end | |||
return nil | |||
end | end | ||
| Line 395: | Line 405: | ||
return cells | return cells | ||
end | |||
-- Renders the amount of Debuff Resist an ability grants. | |||
-- Upgrades stack additively onto the base value, so every step after the first | |||
-- shows the running total: "20% (T3)" when granted only by an upgrade, | |||
-- "10% → 25% (T2)" when a base value is later increased. Chains for any number | |||
-- of steps. No ability currently has both a base and an upgrade value. | |||
function p.RenderExtraDebuffResist(ability) | |||
local fields = Lists.lists["extradebuffresist"] | |||
local segments = {} | |||
local running = layer_value(ability, fields) | |||
if running then | |||
table.insert(segments, running .. "%") | |||
end | |||
local upgrades = ability["Upgrades"] | |||
if type(upgrades) == "table" then | |||
for i, tier in ipairs(upgrades) do | |||
if type(tier) == "table" then | |||
local delta = layer_value(tier, fields) | |||
if delta then | |||
running = (running or 0) + delta | |||
table.insert(segments, running .. "% (T" .. i .. ")") | |||
end | |||
end | |||
end | |||
end | |||
if #segments == 0 then return {} end | |||
return { ["Debuff Resist"] = table.concat(segments, " → ") } | |||
end | end | ||
return p | return p | ||