Module:AbilityTable: Difference between revisions

Jump to navigation Jump to search
Vergir (talk | contribs)
Refactor human note merging: full table uses ". " separator with capitalisation/period normalisation; compact uses "; " with decapitalisation/period stripping (with T1/T2/T3 prefix guard) (with help from vergir-bot LLM)
Vergir (talk | contribs)
Auto-notes no longer generate trailing periods; ensure_period applied to final Notes string in full-table mode instead, fixing double-dot when auto and human notes combine (with help from vergir-bot LLM)
Line 190: Line 190:
-- ============================================================
-- ============================================================


-- Full-table mode: capitalise first letter, ensure trailing ".".
-- Capitalises the first letter of a human note before merging.
-- Only used for full-table mode.
local function human_note_full(note)
local function human_note_full(note)
     if not note or note == "" then return note end
     if not note or note == "" then return note end
     note = note:sub(1,1):upper() .. note:sub(2)
     return note:sub(1,1):upper() .. note:sub(2)
     if note:sub(-1) ~= "." then note = note .. "." end
end
     return note
 
-- Ensures the final merged Notes string ends with "." for full-table mode.
-- Applied after all merging is done, so it covers auto-only, human-only, and combined.
local function ensure_period(s)
    if not s or s == "" then return s end
     if s:sub(-1) ~= "." then s = s .. "." end
     return s
end
end


Line 390: Line 397:
         local charge_str = n .. " charge" .. (n ~= 1 and "s" or "")
         local charge_str = n .. " charge" .. (n ~= 1 and "s" or "")
         if has_base then
         if has_base then
             table.insert(note_parts, "+" .. charge_str .. " on T" .. upgrade_info.tier .. " upgrade.")
             table.insert(note_parts, "+" .. charge_str .. " on T" .. upgrade_info.tier .. " upgrade")
         else
         else
             local cd_str = upgrade_cooldown and (upgrade_cooldown .. "s") or "unknown"
             local cd_str = upgrade_cooldown and (upgrade_cooldown .. "s") or "unknown"
             table.insert(note_parts, "Becomes charged on T" .. upgrade_info.tier
             table.insert(note_parts, "Becomes charged on T" .. upgrade_info.tier
                 .. " upgrade with " .. charge_str
                 .. " upgrade with " .. charge_str
                 .. " and " .. cd_str .. " time between charges.")
                 .. " and " .. cd_str .. " time between charges")
         end
         end
     end
     end
     if ability["AbilityChargesConditionally"] ~= nil then
     if ability["AbilityChargesConditionally"] ~= nil then
         table.insert(note_parts, "Has a conditional charge.")
         table.insert(note_parts, "Has a conditional charge")
     end
     end
     if #note_parts > 0 then
     if #note_parts > 0 then
Line 438: Line 445:
                         if stype == "heavy_melee" and delta > 0 then
                         if stype == "heavy_melee" and delta > 0 then
                             table.insert(notes, "T" .. i .. " upgrade changes scaling to ×"
                             table.insert(notes, "T" .. i .. " upgrade changes scaling to ×"
                                 .. delta .. " of Heavy Melee damage.")
                                 .. delta .. " of Heavy Melee damage")
                         elseif stype == "melee" and delta ~= 0 and base_melee_scale then
                         elseif stype == "melee" and delta ~= 0 and base_melee_scale then
                             local final = math.floor((base_melee_scale + delta) * 1000 + 0.5) / 1000
                             local final = math.floor((base_melee_scale + delta) * 1000 + 0.5) / 1000
                             table.insert(notes, "T" .. i .. " upgrade adds ×"
                             table.insert(notes, "T" .. i .. " upgrade adds ×"
                                 .. delta .. " scaling (total ×" .. final .. ").")
                                 .. delta .. " scaling (total ×" .. final .. ")")
                         end
                         end
                     end
                     end
Line 528: Line 535:
                         local total = (running or 0) + delta
                         local total = (running or 0) + delta
                         table.insert(notes, "T" .. i .. " upgrade increases heal reduction by "
                         table.insert(notes, "T" .. i .. " upgrade increases heal reduction by "
                             .. delta .. "% (total " .. total .. "%).")
                             .. delta .. "% (total " .. total .. "%)")
                         running = total
                         running = total
                     end
                     end
Line 571: Line 578:
                         table.insert(notes, "T" .. i .. " upgrade increases "
                         table.insert(notes, "T" .. i .. " upgrade increases "
                             .. col_name:lower() .. " by " .. delta .. suffix
                             .. col_name:lower() .. " by " .. delta .. suffix
                             .. " (total " .. total .. suffix .. ").")
                             .. " (total " .. total .. suffix .. ")")
                         running = total
                         running = total
                     end
                     end
Line 588: Line 595:
     local channel_slow = num_val(ability["ChannelSlowPercent"])
     local channel_slow = num_val(ability["ChannelSlowPercent"])
     if channel_slow and channel_slow ~= 0 then
     if channel_slow and channel_slow ~= 0 then
         local note = "Also slows the caster for " .. math.abs(channel_slow) .. "%."
         local note = "Also slows the caster for " .. math.abs(channel_slow) .. "%"
         cells["Notes"] = cells["Notes"] and (cells["Notes"] .. "; " .. note) or note
         cells["Notes"] = cells["Notes"] and (cells["Notes"] .. "; " .. note) or note
     end
     end
Line 639: Line 646:


     if caster_dash_slow then
     if caster_dash_slow then
         local note = "Gives " .. caster_dash_slow .. "% dash slow for the caster."
         local note = "Gives " .. caster_dash_slow .. "% dash slow for the caster"
         cells["Notes"] = cells["Notes"] and (cells["Notes"] .. "; " .. note) or note
         cells["Notes"] = cells["Notes"] and (cells["Notes"] .. "; " .. note) or note
     end
     end
Line 858: Line 865:
             extra["Notes"] = extra["Notes"] and (extra["Notes"] .. ". " .. human) or human
             extra["Notes"] = extra["Notes"] and (extra["Notes"] .. ". " .. human) or human
         end
         end
        extra["Notes"] = ensure_period(extra["Notes"])


         local row = '| class="ability-table-cell-hero" | '    .. hero_cell
         local row = '| class="ability-table-cell-hero" | '    .. hero_cell