Module:GamePassives: Difference between revisions
From SpiritVale Wiki
More actions
No edit summary |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 45: | Line 45: | ||
end | end | ||
-- | -- Tag body rows so we can style/center without touching the hero row | ||
local function addRow(tbl, label, value) | local function addRow(tbl, label, value) | ||
if value == nil or value == "" then | if value == nil or value == "" then | ||
| Line 56: | Line 56: | ||
end | end | ||
-- | -- Tag section header rows as body rows too (for centering) | ||
local function addSectionHeader(tbl, label) | local function addSectionHeader(tbl, label) | ||
local row = tbl:tag("tr") | local row = tbl:tag("tr") | ||
| Line 94: | Line 94: | ||
-- Formatting helpers | -- Formatting helpers | ||
---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ||
local function asUl(items) | |||
if type(items) ~= "table" or #items == 0 then | |||
return nil | |||
end | |||
return '<ul class="spiritvale-infobox-list"><li>' | |||
.. table.concat(items, "</li><li>") | |||
.. "</li></ul>" | |||
end | |||
local function formatBasePer(block) | local function formatBasePer(block) | ||
| Line 112: | Line 121: | ||
end | end | ||
local function | -- Passive Effects: return rows (label/value), not a single text blob | ||
local function passiveEffectRows(list) | |||
if type(list) ~= "table" or #list == 0 then | if type(list) ~= "table" or #list == 0 then | ||
return | return {} | ||
end | end | ||
local | local rows = {} | ||
for _, eff in ipairs(list) do | for _, eff in ipairs(list) do | ||
| Line 123: | Line 133: | ||
local t = eff.Type or {} | local t = eff.Type or {} | ||
local name = t.Name or eff.ID or "Unknown" | local name = t.Name or eff.ID or "Unknown" | ||
local value = eff.Value or {} | local value = eff.Value or {} | ||
local detail = {} | local detail = {} | ||
| Line 137: | Line 147: | ||
end | end | ||
local | -- Optional qualifiers (weapon/stance/etc.), if present in data | ||
if | local qual = eff.Weapon or eff["Weapon"] or eff["Weapon Type"] | ||
or eff.Stance or eff["Stance"] or eff["Stance Type"] | |||
if type(qual) == "string" and qual ~= "" then | |||
table.insert(detail, qual) | |||
end | end | ||
table.insert( | local right = (#detail > 0) and table.concat(detail, ", ") or "—" | ||
table.insert(rows, { label = name, value = right }) | |||
end | end | ||
end | end | ||
return rows | |||
end | end | ||
| Line 196: | Line 205: | ||
end | end | ||
return asUl(parts) | |||
return | |||
end | end | ||
| Line 230: | Line 235: | ||
end | end | ||
return asUl(parts) | |||
return | |||
end | end | ||
| Line 247: | Line 248: | ||
local action = ev.Action or "On event" | local action = ev.Action or "On event" | ||
local name = ev["Skill Name"] or ev["Skill ID"] or "Unknown skill" | local name = ev["Skill Name"] or ev["Skill ID"] or "Unknown skill" | ||
table.insert(parts, string.format("%s → %s", action, name)) | |||
end | end | ||
end | end | ||
return asUl(parts) | |||
return | |||
end | end | ||
| Line 286: | Line 282: | ||
collect("Special", mods["Special Modifiers"]) | collect("Special", mods["Special Modifiers"]) | ||
return asUl(parts) | |||
return | |||
end | end | ||
| Line 380: | Line 372: | ||
addSectionHeader(root, "General") | addSectionHeader(root, "General") | ||
addRow(root, "Max | addRow(root, "Max Level", rec["Max Level"] and tostring(rec["Max Level"])) | ||
-- | -- Classes intentionally removed (template is used on class pages) | ||
local users = rec.Users or {} | local users = rec.Users or {} | ||
addRow(root, "Summons", listToText(users.Summons)) | addRow(root, "Summons", listToText(users.Summons)) | ||
addRow(root, "Monsters", listToText(users.Monsters)) | addRow(root, "Monsters", listToText(users.Monsters)) | ||
| Line 410: | Line 401: | ||
end | end | ||
end | end | ||
addRow(root, "Required | addRow(root, "Required Skills", table.concat(skillParts, ", ")) | ||
end | end | ||
addRow(root, "Required | addRow(root, "Required Weapons", listToText(req["Required Weapons"])) | ||
addRow(root, "Required | addRow(root, "Required Stances", listToText(req["Required Stances"])) | ||
end | end | ||
------------------------------------------------------------------ | ------------------------------------------------------------------ | ||
-- Passive | -- Passive Effects (one row per effect) | ||
------------------------------------------------------------------ | ------------------------------------------------------------------ | ||
local | local peRows = passiveEffectRows(rec["Passive Effects"]) | ||
if | if #peRows > 0 then | ||
addSectionHeader(root, "Passive | addSectionHeader(root, "Passive Effects") | ||
addRow(root, "Effects", | for _, r in ipairs(peRows) do | ||
addRow(root, r.label, r.value) | |||
end | |||
end | |||
------------------------------------------------------------------ | |||
-- Status Effects | |||
------------------------------------------------------------------ | |||
local statusApps = formatStatusApplications(rec["Status Applications"]) | |||
local statusRem = formatStatusRemoval(rec["Status Removal"]) | |||
if statusApps or statusRem then | |||
addSectionHeader(root, "Status Effects") | |||
addRow(root, "Applies", statusApps) | |||
addRow(root, "Removes", statusRem) | |||
end | end | ||
| Line 433: | Line 437: | ||
addSectionHeader(root, "Modifiers") | addSectionHeader(root, "Modifiers") | ||
addRow(root, "Flags", modsText) | addRow(root, "Flags", modsText) | ||
end | end | ||
| Line 460: | Line 453: | ||
if type(rec.Notes) == "table" and #rec.Notes > 0 then | if type(rec.Notes) == "table" and #rec.Notes > 0 then | ||
addSectionHeader(root, "Notes") | addSectionHeader(root, "Notes") | ||
addRow(root, "Notes", table.concat(rec.Notes, "<br />")) | addRow(root, "Notes", asUl(rec.Notes) or table.concat(rec.Notes, "<br />")) | ||
end | end | ||