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 1,179: Line 1,179:
local maxLevel = ctx.maxLevel or 1
local maxLevel = ctx.maxLevel or 1


local mech = (type(rec) == "table" and type(rec.Mechanics) == "table") and rec.Mechanics or {}
local mech   = (type(rec) == "table" and type(rec.Mechanics) == "table") and rec.Mechanics or {}
local effects = (type(mech.Effects) == "table") and mech.Effects or nil
local effects = (type(mech.Effects) == "table") and mech.Effects or nil
local combo  = (type(mech.Combo) == "table") and mech.Combo or nil
local combo  = (type(mech.Combo) == "table") and mech.Combo or nil
local mods    = (type(rec.Modifiers) == "table") and rec.Modifiers or nil
local mods    = (type(rec.Modifiers) == "table") and rec.Modifiers or nil


-- Collect flags as a flat, de-duped set
------------------------------------------------------------------
-- Flags (flat, de-duped)
------------------------------------------------------------------
local flagSet = {}
local flagSet = {}


Line 1,211: Line 1,213:
table.sort(flags)
table.sort(flags)


-- Collect special mechanics into (label,value) items
------------------------------------------------------------------
local items = {}
-- Special mechanics (label/value items)
------------------------------------------------------------------
local mechItems = {}


if effects then
if effects then
Line 1,225: Line 1,229:
local t = trim(block.Type)
local t = trim(block.Type)


local parts = {}
local value = nil
if t and not isNoneLike(t) and mw.ustring.lower(t) ~= mw.ustring.lower(tostring(name)) then
table.insert(parts, mw.text.nowiki(t))
end
if disp then
if disp then
table.insert(parts, disp)
value = disp
end
end


local value = nil
-- If Type exists and is distinct, prefix it (keeps your previous behavior)
if #parts == 1 then
if t and not isNoneLike(t) and mw.ustring.lower(t) ~= mw.ustring.lower(tostring(name)) then
value = parts[1]
if value then
elseif #parts >= 2 then
value = mw.text.nowiki(t) .. ": " .. value
value = parts[1] .. ": " .. parts[2]
else
value = mw.text.nowiki(t)
end
end
end


if value then
if value then
table.insert(items, { label = tostring(name), value = value })
table.insert(mechItems, { label = tostring(name), value = value })
end
end
end
end
Line 1,247: Line 1,250:
end
end


-- Combo (append last)
------------------------------------------------------------------
-- Combo (separate group)
------------------------------------------------------------------
local comboText = nil
if combo then
if combo then
local typ = trim(combo.Type)
local typ = trim(combo.Type)
Line 1,263: Line 1,269:
end
end


local comboText
if #details > 0 then
if #details > 0 then
comboText = mw.text.nowiki(typ) .. " (" .. table.concat(details, ", ") .. ")"
comboText = mw.text.nowiki(typ) .. " (" .. table.concat(details, ", ") .. ")"
Line 1,269: Line 1,274:
comboText = mw.text.nowiki(typ)
comboText = mw.text.nowiki(typ)
end
end
table.insert(items, { label = "Combo", value = comboText })
end
end
end
end


local hasAny = (#flags > 0) or (#items > 0)
------------------------------------------------------------------
-- Presence + empty fallback
------------------------------------------------------------------
local hasFlags = (#flags > 0)
local hasMech  = (#mechItems > 0)
local hasCombo = (comboText ~= nil and comboText ~= "")


local root = mw.html.create("div")
if (not hasFlags) and (not hasMech) and (not hasCombo) then
root:addClass("sv-sm-root")
local root = mw.html.create("div")
root:addClass("sv-compact-root")
root:addClass("sv-sm-root")
root:addClass("sv-compact-root")
root:tag("div"):addClass("sv-sm-empty"):wikitext("No Special Mechanics")


if not hasAny then
root:tag("div")
:addClass("sv-sm-empty")
:wikitext("No Special Mechanics")
return {
return {
inner = tostring(root),
inner = tostring(root),
Line 1,289: Line 1,295:
}
}
end
end
local count = 0
if hasFlags then count = count + 1 end
if hasMech  then count = count + 1 end
if hasCombo then count = count + 1 end
------------------------------------------------------------------
-- Markup: 3 columns on desktop when all present; mobile CSS collapses
------------------------------------------------------------------
local root = mw.html.create("div")
root:addClass("sv-sm-root")
root:addClass("sv-compact-root")


local layout = root:tag("div"):addClass("sv-sm-layout")
local layout = root:tag("div"):addClass("sv-sm-layout")
if #flags > 0 then
layout:addClass("sv-sm-count-" .. tostring(count))
layout:addClass("sv-sm-has-flags")
if hasFlags then layout:addClass("sv-sm-has-flags") end
local fcol = layout:tag("div"):addClass("sv-sm-flags")
if hasMech  then layout:addClass("sv-sm-has-mech") end
if hasCombo then layout:addClass("sv-sm-has-combo") end
 
-- Column 1: Flags
if hasFlags then
local fcol = layout:tag("div"):addClass("sv-sm-col"):addClass("sv-sm-col-flags")
for _, f in ipairs(flags) do
for _, f in ipairs(flags) do
fcol:tag("div"):addClass("sv-sm-flag"):wikitext(mw.text.nowiki(f))
fcol:tag("div"):addClass("sv-sm-flag"):wikitext(mw.text.nowiki(f))
Line 1,299: Line 1,322:
end
end


local wrap = layout:tag("div"):addClass("sv-sm-items")
-- Column 2: Special Mechanics (stacked)
for _, it in ipairs(items) do
if hasMech then
local one = wrap:tag("div"):addClass("sv-sm-item")
local mcol = layout:tag("div"):addClass("sv-sm-col"):addClass("sv-sm-col-mech")
one:tag("div"):addClass("sv-sm-label"):wikitext(mw.text.nowiki(it.label))
for _, it in ipairs(mechItems) do
one:tag("div"):addClass("sv-sm-value"):wikitext(it.value or "—")
local one = mcol:tag("div"):addClass("sv-sm-mech")
one:tag("div"):addClass("sv-sm-label"):wikitext(mw.text.nowiki(it.label))
one:tag("div"):addClass("sv-sm-value"):wikitext(it.value or "—")
end
end
 
-- Column 3: Combo
if hasCombo then
local ccol = layout:tag("div"):addClass("sv-sm-col"):addClass("sv-sm-col-combo")
local one = ccol:tag("div"):addClass("sv-sm-mech"):addClass("sv-sm-combo")
one:tag("div"):addClass("sv-sm-label"):wikitext("Combo")
one:tag("div"):addClass("sv-sm-value"):wikitext(comboText or "—")
end
end


Line 1,311: Line 1,345:
}
}
end
end


----------------------------------------------------------------------
----------------------------------------------------------------------