Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Join the Playtest on Steam Now: SpiritVale

Module:GameSkills: Difference between revisions

From SpiritVale Wiki
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")
 
:attr("type", "range")
if tonumber(maxLevel) and tonumber(maxLevel) > 1 then
:attr("min", "1")
slider:tag("input")
:attr("max", tostring(maxLevel))
:attr("type", "range")
:attr("value", tostring(level))
:attr("min", "1")
:addClass("sv-level-range")
:attr("max", tostring(maxLevel))
:attr("aria-label", "Skill level select")
: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)
-- - RULE: If BOTH Source and Scaling are missing -> return nil (slot stays blank)
-- UPDATES:
-- - Supports BOTH new (rec.Source) and legacy (rec.Damage) formats.
--  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 basisCol = wrap:tag("div"):addClass("sv-source-col"):addClass("sv-source-basis")
-- Row 1: header pills (kept parallel)
basisCol:tag("div")
local head = wrap:tag("div"):addClass("sv-source-row"):addClass("sv-source-head")
:addClass("sv-basis-word")
:wikitext(mw.text.nowiki(basisWord or ""))


local sourceCol = wrap:tag("div"):addClass("sv-source-col"):addClass("sv-source-main")
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
sourceCol:tag("div")
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(mw.text.nowiki(sourceKind or "Source"))
:wikitext("Scaling")
end


sourceCol:tag("div")
-- 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 scalingCol = wrap:tag("div"):addClass("sv-source-col"):addClass("sv-source-scaling")
local scalingBody = addCell(body, "sv-source-scaling")
if hasScaling then
if hasScaling then
scalingCol:tag("div")
local list = scalingBody:tag("div"):addClass("sv-scaling-list")
:addClass("sv-source-pill")
:wikitext("Scaling")
 
local list = scalingCol:tag("div"):addClass("sv-scaling-list")
for _, line in ipairs(scalingLines) do
for _, line in ipairs(scalingLines) do
list:tag("div")
list:tag("div")