Module:GameSkills: Difference between revisions
From SpiritVale Wiki
More actions
No edit summary |
No edit summary |
||
| Line 880: | Line 880: | ||
-- ------------------------------------------------------------ | -- ------------------------------------------------------------ | ||
-- Module 1 – Level Selector | -- Module 1 – Level Selector | ||
-- FIX: If maxLevel == 1, do NOT emit a range input (prevents JS edge-cases) | |||
-- ------------------------------------------------------------ | -- ------------------------------------------------------------ | ||
local function buildModuleLevelSelector(level, maxLevel) | local function buildModuleLevelSelector(level, maxLevel) | ||
| Line 894: | Line 895: | ||
local slider = inner:tag("div"):addClass("sv-level-slider") | local slider = inner:tag("div"):addClass("sv-level-slider") | ||
slider:tag("input") | |||
if tonumber(maxLevel) and tonumber(maxLevel) > 1 then | |||
slider:tag("input") | |||
:attr("type", "range") | |||
:attr("min", "1") | |||
:attr("max", tostring(maxLevel)) | |||
:attr("value", tostring(level)) | |||
:addClass("sv-level-range") | |||
:attr("aria-label", "Skill level select") | |||
else | |||
-- single-level skills: keep layout but no <input> | |||
inner:addClass("sv-level-ui-single") | |||
slider:addClass("sv-level-slider-single") | |||
end | |||
return moduleBox(1, "module-level-selector", tostring(inner), false) | return moduleBox(1, "module-level-selector", tostring(inner), false) | ||
| Line 952: | Line 960: | ||
-- ============================================================ | -- ============================================================ | ||
-- Module 3 – Skill Source (Basis + Source + Scaling) | -- Module 3 – Skill Source (Basis + Source + Scaling) | ||
-- - | -- UPDATES: | ||
-- | -- 1) If basisWord is nil/empty -> hide column 1 entirely | ||
-- 2) Basis word is bold + emphasis; "Magic Attack" forced to wrap nicely | |||
-- 3) Source/Scaling pills always align (header row), regardless of scaling height | |||
-- ============================================================ | -- ============================================================ | ||
| Line 1,047: | Line 1,057: | ||
return nil | return nil | ||
end | |||
local function buildBasisMarkup(word) | |||
if not word or word == "" then | |||
return nil | |||
end | |||
local wrap = mw.html.create("div") | |||
wrap:addClass("sv-basis-word") | |||
wrap:addClass("sv-basis-emph") | |||
local strong = wrap:tag("strong") | |||
if word == "Magic Attack" then | |||
-- forced clean wrap at the desired boundary | |||
strong:wikitext("Magic<br />Attack") | |||
else | |||
strong:wikitext(mw.text.nowiki(word)) | |||
end | |||
return tostring(wrap) | |||
end | end | ||
| Line 1,119: | Line 1,150: | ||
return nil | return nil | ||
end | end | ||
local basisMarkup = buildBasisMarkup(basisWord) | |||
local hasBasis = (basisMarkup ~= nil and basisMarkup ~= "") | |||
local extra = { "skill-source-module" } | local extra = { "skill-source-module" } | ||
if hasSource then table.insert(extra, "sv-has-source") end | if hasSource then table.insert(extra, "sv-has-source") end | ||
if hasScaling then table.insert(extra, "sv-has-scaling") end | if hasScaling then table.insert(extra, "sv-has-scaling") end | ||
if hasBasis then | |||
table.insert(extra, "sv-has-basis") | |||
else | |||
table.insert(extra, "sv-no-basis") | |||
end | |||
local wrap = mw.html.create("div") | local wrap = mw.html.create("div") | ||
wrap:addClass("sv-source-grid") | wrap:addClass("sv-source-grid") | ||
wrap:addClass(hasBasis and "sv-source-cols-3" or "sv-source-cols-2") | |||
-- Helper to add a cell | |||
local function addCell(row, colClass) | |||
local c = row:tag("div") | |||
c:addClass("sv-source-cell") | |||
if colClass then c:addClass(colClass) end | |||
return c | |||
end | |||
local | -- Row 1: header pills (kept parallel) | ||
local head = wrap:tag("div"):addClass("sv-source-row"):addClass("sv-source-head") | |||
if hasBasis then | |||
addCell(head, "sv-source-basis-head") -- empty header cell for alignment | |||
end | |||
local sourceHead = addCell(head, "sv-source-main-head") | |||
if hasSource then | if hasSource then | ||
sourceHead:tag("div") | |||
:addClass("sv-source-pill") | |||
:wikitext(mw.text.nowiki(sourceKind or "Damage")) | |||
end | |||
local scalingHead = addCell(head, "sv-source-scaling-head") | |||
if hasScaling then | |||
scalingHead:tag("div") | |||
:addClass("sv-source-pill") | :addClass("sv-source-pill") | ||
:wikitext( | :wikitext("Scaling") | ||
end | |||
-- Row 2: values/content | |||
local body = wrap:tag("div"):addClass("sv-source-row"):addClass("sv-source-body") | |||
if hasBasis then | |||
addCell(body, "sv-source-basis"):wikitext(basisMarkup) | |||
end | |||
local sourceBody = addCell(body, "sv-source-main") | |||
if hasSource then | |||
sourceBody:tag("div") | |||
:addClass("sv-source-value") | :addClass("sv-source-value") | ||
:wikitext(sourceVal) | :wikitext(sourceVal) | ||
end | end | ||
local | local scalingBody = addCell(body, "sv-source-scaling") | ||
if hasScaling then | if hasScaling then | ||
local list = scalingBody:tag("div"):addClass("sv-scaling-list") | |||
local list = | |||
for _, line in ipairs(scalingLines) do | for _, line in ipairs(scalingLines) do | ||
list:tag("div") | list:tag("div") | ||