Module:AbilityTable: Difference between revisionsGive feedback
Jump to navigation
Jump to search
add debug output to debuff_cells for Shoulder Charge to diagnose missing note (with help from vergir-bot LLM) |
fix debuff_cells: remove debug, replace #upgrades loop with sorted pairs iteration to fix empty notes (with help from vergir-bot LLM) |
||
| Line 172: | Line 172: | ||
end | end | ||
local function find_in_upgrades(ability, field) | local function find_in_upgrades(ability, field) | ||
local upgrades = ability["Upgrades"] | local upgrades = ability["Upgrades"] | ||
| Line 185: | Line 183: | ||
end | end | ||
local function find_first_value(ability, fields) | local function find_first_value(ability, fields) | ||
for _, field in ipairs(fields) do | for _, field in ipairs(fields) do | ||
| Line 271: | Line 267: | ||
} | } | ||
-- Returns | -- Returns true if prop is found with a non-zero value anywhere in the record | ||
-- | -- excluding the Upgrades key. Mirrors GameData.record_matches_prop logic. | ||
local function prop_in_base(record, prop) | local function prop_in_base(record, prop) | ||
for k, v in pairs(record) do | for k, v in pairs(record) do | ||
| Line 291: | Line 287: | ||
end | end | ||
-- Renderer shared by debuffresist and dispelmagic. | |||
-- Outputs a Notes cell describing which debuffs are added only by upgrades. | |||
-- If any prop from the stat's list is found in the base ability, outputs nothing. | |||
-- Otherwise lists per-tier debuff names: "T2 slow", "T1 slow, T2 silence", etc. | |||
local function debuff_cells(ability, stat) | local function debuff_cells(ability, stat) | ||
local props = stat_to_props[stat] | local props = stat_to_props[stat] | ||
local cells = {} | local cells = {} | ||
-- | -- If any prop exists in base, this is a base-level debuff — no note needed. | ||
for _, prop in ipairs(props) do | for _, prop in ipairs(props) do | ||
if prop_in_base(ability, prop) then | if prop_in_base(ability, prop) then | ||
return cells | |||
end | end | ||
end | end | ||
local upgrades = ability["Upgrades"] | local upgrades = ability["Upgrades"] | ||
if type(upgrades) ~= "table" then return cells end | if type(upgrades) ~= "table" then return cells end | ||
-- Collect debuff short names per upgrade tier. | |||
local tier_debuffs = {} | local tier_debuffs = {} | ||
local seen_names = {} | local seen_names = {} -- deduplicate short names across all tiers | ||
for i, tier in ipairs(upgrades) do | for i, tier in ipairs(upgrades) do | ||
| Line 366: | Line 334: | ||
end | end | ||
end | end | ||
-- Build note in tier order using sorted keys to avoid Lua pairs() ordering issues. | |||
local tier_indices = {} | |||
for i in pairs(tier_debuffs) do | |||
table.insert(tier_indices, i) | |||
end | |||
table.sort(tier_indices) | |||
local parts = {} | local parts = {} | ||
for i | for _, i in ipairs(tier_indices) do | ||
table.insert(parts, "T" .. i .. " " .. table.concat(tier_debuffs[i], " + ")) | |||
end | end | ||
| Line 602: | Line 575: | ||
end | end | ||
if # | if #parts > 0 then cells["Notes"] = table.concat(notes, " ") end | ||
return cells | return cells | ||
end | end | ||