Editing Module:AbilityTable/ComplexRenderersGive feedback
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
| Latest revision | Your text | ||
| Line 47: | Line 47: | ||
end | end | ||
-- | -- Returns true if prop exists with a non-zero value at the top level of the | ||
-- | -- record, excluding the Upgrades key. Does not recurse into sub-tables to | ||
-- avoid false positives from modifier metadata (e.g. prop names appearing as | |||
-- string values inside AutoRegisterModifierValueFromAbilityPropertyName). | |||
-- Value-objects like { Value = N } are unwrapped via the k == prop branch. | |||
-- Name-based list entries (e.g. "Card Trick") match via the string branch | |||
-- against the top-level Name field. | |||
local function is_base_property(record, prop) | |||
for k, v in pairs(record) do | |||
if k == "Upgrades" then | |||
-- skip | |||
-- | elseif k == prop then | ||
- | if type(v) == "table" then v = v["Value"] end | ||
-- | if v ~= nil and v ~= 0 and v ~= "" and v ~= "0" and v ~= "0m" then | ||
- | return true | ||
local function | |||
for | |||
if type( | |||
end | end | ||
if v | elseif type(v) == "string" then | ||
if v == prop then return true end | |||
end | end | ||
end | end | ||
return false | |||
end | 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 | |||
local function | 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 | |||
local | |||
end | end | ||
end | end | ||
return | return nil | ||
end | end | ||
| Line 168: | Line 143: | ||
local p = {} | local p = {} | ||
-- Renders charge count and time between charges. | -- Renders charge count and time between charges. | ||
| Line 206: | Line 148: | ||
function p.RenderCharges(ability) | function p.RenderCharges(ability) | ||
local base_charges = unwrap_value(ability["AbilityCharges"]) | local base_charges = unwrap_value(ability["AbilityCharges"]) | ||
local base_cooldown = | local base_cooldown = ability["AbilityCooldownBetweenCharge"] | ||
local has_base = base_charges ~= nil and base_charges > 0 | local has_base = base_charges ~= nil and base_charges > 0 | ||
local upgrade_info = find_in_upgrades(ability, "AbilityCharges") | local upgrade_info = find_in_upgrades(ability, "AbilityCharges") | ||
| Line 404: | Line 346: | ||
end | end | ||
-- Renders | -- Renders heal reduction percentage. | ||
-- | -- Special case for DisableHealing, shown as 100%. | ||
function p. | function p.RenderHealReduce(ability) | ||
local | -- DisableHealing is always 100%, handle it separately | ||
local | local v = unwrap_value(ability["DisableHealing"]) | ||
if v and v ~= 0 then | |||
return { ["Heal Reduction"] = "100%" } | |||
end | |||
local upgrade = find_in_upgrades(ability, "DisableHealing") | |||
if upgrade then | |||
return { ["Heal Reduction"] = "100% (T" .. upgrade.tier .. ")" } | |||
end | |||
-- | -- Everything else goes through the generic renderer | ||
for | local filtered = {} | ||
if | for _, prop in ipairs(Lists.lists["healreduce"]) do | ||
if prop ~= "DisableHealing" then table.insert(filtered, prop) end | |||
end | end | ||
return render_upgradable_stat(ability, "Heal Reduction", filtered, "%") | |||
end | |||
-- Shows a note if an ability only acquires a dispellable debuff via upgrades. | |||
-- Shared by debuffresist and dispelmagic. | |||
function p.RenderDebuff(ability, stat) | |||
local stat_props = Lists.lists[stat] | |||
local cells = {} | local cells = {} | ||
if | -- If any prop exists in base, this is a base-level debuff — no note needed. | ||
for _, prop in ipairs(stat_props) do | |||
if is_base_property(ability, prop) then | |||
return cells | |||
end | |||
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 | ||
for i, tier in ipairs(upgrades) do | for i, tier in ipairs(upgrades) do | ||
if type(tier) == "table" then | if type(tier) == "table" then | ||
for _, prop in ipairs(stat_props) do | |||
local v = tier[prop] | |||
for | if v ~= nil then | ||
if type(v) == "table" then | 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 | cells["Notes"] = "After T" .. i | ||
return cells | |||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
return cells | return cells | ||
end | end | ||
| Line 556: | Line 470: | ||
return cells | return cells | ||
end | end | ||
return p | return p | ||