Module:AbilityTable: Difference between revisionsGive feedback
refactor abilitytable to use submodules |
consolidate three note formatters into two: enrich_notes_full and enrich_notes_compact (with help from vergir-bot LLM) |
||
| Line 46: | Line 46: | ||
-- ============================================================ | -- ============================================================ | ||
-- | -- Note enrichment | ||
-- ============================================================ | -- ============================================================ | ||
-- | -- Merges auto-generated and human notes for full-table mode. | ||
local function | -- Capitalizes human note, joins with ". ", ensures trailing period. | ||
if | local function enrich_notes_full(extra, human_note) | ||
if human_note then | |||
human_note = human_note:sub(1,1):upper() .. human_note:sub(2) | |||
extra["Notes"] = extra["Notes"] and (extra["Notes"] .. ". " .. human_note) or human_note | |||
end | |||
if extra["Notes"] and extra["Notes"]:sub(-1) ~= "." then | |||
extra["Notes"] = extra["Notes"] .. "." | |||
end | |||
end | end | ||
-- | -- Merges auto-generated and human notes for compact mode. | ||
-- Decapitalizes human note (skips T{N} prefixes like "T1 slow"), | |||
-- joins with "; ", strips trailing period. | |||
local function enrich_notes_compact(extra, human_note) | |||
if human_note then | |||
local first = human_note:sub(1,1) | |||
if first:match("%u") and not human_note:sub(2,2):match("%d") then | |||
-- | human_note = first:lower() .. human_note:sub(2) | ||
end | |||
local function | if human_note:sub(-1) == "." then human_note = human_note:sub(1, -2) end | ||
if | extra["Notes"] = extra["Notes"] and (extra["Notes"] .. "; " .. human_note) or human_note | ||
end | end | ||
end | end | ||
| Line 225: | Line 226: | ||
local extra = get_cells(ability) | local extra = get_cells(ability) | ||
enrich_notes_compact(extra, stat_notes and stat_notes[name]) | |||
local note = extra["Notes"] | local note = extra["Notes"] | ||
| Line 279: | Line 277: | ||
local extra = get_cells(ability) | local extra = get_cells(ability) | ||
enrich_notes_full(extra, stat_notes and stat_notes[ability["Name"]]) | |||
local row = '| class="ability-table-cell-hero" | ' .. hero_cell | local row = '| class="ability-table-cell-hero" | ' .. hero_cell | ||