Module:AbilityTable: Difference between revisions

Vergir (talk | contribs)
Refine healreduce renderer: show first heal reduction value with upgrade tier in parentheses if upgrade-only; no wiki links in notes (with help from vergir-bot LLM)
Vergir (talk | contribs)
Fix heal reduction upgrade note to use "increases by X% (total Y%)" style, consistent with duration notes (with help from vergir-bot LLM)
Line 208: Line 208:
     -- Determine the first heal reduction value and where it comes from.
     -- Determine the first heal reduction value and where it comes from.
     -- Check base fields first, then scan upgrades in order.
     -- Check base fields first, then scan upgrades in order.
     local first_pct       = nil  -- absolute percent value (positive)
     local first_pct       = nil  -- absolute percent value (positive)
     local first_tier     = nil  -- nil = base ability, N = upgrade tier
     local first_tier       = nil  -- nil = base ability, N = upgrade tier
     local first_is_disable = false
     local first_is_disable = false


Line 264: Line 264:
     local upgrades = ability["Upgrades"]
     local upgrades = ability["Upgrades"]
     if type(upgrades) == "table" then
     if type(upgrades) == "table" then
         local running_pct = first_pct   -- track cumulative for additive note text
         local running_pct     = first_pct
         local running_dur = base_dur
         local running_dur     = base_dur
         local first_pct_seen = (first_tier == nil)  -- if base, we've already "seen" it
         local first_pct_seen = (first_tier == nil)  -- if base, already "seen"


         for i, tier in ipairs(upgrades) do
         for i, tier in ipairs(upgrades) do
Line 283: Line 283:
                     if first_pct then running_pct = first_pct end
                     if first_pct then running_pct = first_pct end
                 elseif first_pct_seen and pct_delta and pct_delta ~= 0 then
                 elseif first_pct_seen and pct_delta and pct_delta ~= 0 then
                     -- Subsequent percent change — note the new total
                     -- Subsequent percent change — "increases by X% (total Y%)"
                     local delta_abs = math.abs(pct_delta)
                     local delta_abs = math.abs(pct_delta)
                     local total = (running_pct or 0) + delta_abs
                     local total     = (running_pct or 0) + delta_abs
                     table.insert(tier_notes, "T" .. i .. " upgrade increases heal reduction to " .. total .. "%.")
                     table.insert(tier_notes, "T" .. i .. " upgrade increases heal reduction by "
                        .. delta_abs .. "% (total " .. total .. "%).")
                     running_pct = total
                     running_pct = total
                 end
                 end