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 10: Line 10:
--
--
-- Requires the JS you installed in MediaWiki:Common.js.
-- Requires the JS you installed in MediaWiki:Common.js.
-- Uses the Common.css classes you added:
--  .sv-topband-cell, .sv-topband-table, .sv-type-table, .sv-level-ui, .sv-level-title, .sv-level-label, .sv-level-slider


local GameData = require("Module:GameData")
local GameData = require("Module:GameData")
Line 816: Line 818:
local wrap = mw.html.create("div")
local wrap = mw.html.create("div")
wrap:addClass("sv-level-ui")
wrap:addClass("sv-level-ui")
wrap:addClass("sv-level-box")


-- Top box (label + current level)
-- Title (matches Common.css)
local top = wrap:tag("div"):addClass("sv-level-top")
wrap:tag("div")
top:tag("div"):addClass("sv-level-title"):wikitext("Level Select")
:addClass("sv-level-title")
top:tag("div"):addClass("sv-level-label")
:wikitext("Level Select")
 
-- Label line
wrap:tag("div")
:addClass("sv-level-label")
:wikitext("Level <span class=\"sv-level-num\">" .. tostring(level) .. "</span> / " .. tostring(maxLevel))
:wikitext("Level <span class=\"sv-level-num\">" .. tostring(level) .. "</span> / " .. tostring(maxLevel))


-- Bottom box (slider placeholder)
-- Slider placeholder (JS will insert the input)
wrap:tag("div"):addClass("sv-level-bottom")
wrap:tag("div"):addClass("sv-level-slider")
:tag("div"):addClass("sv-level-slider")


return tostring(wrap)
return tostring(wrap)
end
end


local function buildTypeListUI(typeBlock)
local function buildTypeTableUI(typeBlock)
if type(typeBlock) ~= "table" or next(typeBlock) == nil then
if type(typeBlock) ~= "table" or next(typeBlock) == nil then
return nil
return nil
end
end


local wrap = mw.html.create("div")
local t = mw.html.create("table")
wrap:addClass("sv-type-box")
t:addClass("sv-type-table")


local function addItem(label, value)
local added = false
if not value or value == "" then return end
local row = wrap:tag("div"):addClass("sv-type-row")
row:tag("span"):addClass("sv-type-key"):wikitext(mw.text.nowiki(label))
row:tag("span"):addClass("sv-type-val"):wikitext(mw.text.nowiki(value))
end


local dt = typeBlock["Damage Type"]
local function valName(x)
if type(dt) == "table" and dt.Name then
if x == nil then return nil end
addItem("Type", dt.Name) -- renamed from "Damage Type"
if type(x) == "table" then
end
if x.Name and x.Name ~= "" then return tostring(x.Name) end
 
if x.ID and x.ID ~= "" then return tostring(x.ID) end
local et = typeBlock["Element Type"]
end
if type(et) == "table" and et.Name then
if type(x) == "string" and x ~= "" then return x end
addItem("Element", et.Name)
return nil
end
end


local tt = typeBlock["Target Type"]
local function addRowKV(k, v)
if type(tt) == "table" and tt.Name then
if not v or v == "" then return end
addItem("Target", tt.Name)
added = true
local r = t:tag("tr")
r:tag("th"):wikitext(mw.text.nowiki(k)):done()
r:tag("td"):wikitext(mw.text.nowiki(v)):done()
end
end


local ct = typeBlock["Cast Type"]
addRowKV("Type",      valName(typeBlock["Damage Type"]))  -- renamed from "Damage Type"
if type(ct) == "table" and ct.Name then
addRowKV("Element",  valName(typeBlock["Element Type"]))
addItem("Cast Type", ct.Name)
addRowKV("Target",    valName(typeBlock["Target Type"]))
end
addRowKV("Cast Type", valName(typeBlock["Cast Type"]))


-- If nothing was added, return nil
if not added then
if not wrap or tostring(wrap) == "" then
return nil
return nil
end
end
return tostring(wrap)
return tostring(t)
end
end


local function addTopBand(tbl, levelUI, typeUI)
local function addTopBand(tbl, levelUI, typeUI)
-- One row (colspan=2) that *contains* a 2-column grid:
--  - left: level select (top text + bottom slider)
--  - right: type list (label/value pairs)
if not levelUI and not typeUI then
if not levelUI and not typeUI then
return
return
Line 886: Line 884:
cell:addClass("sv-topband-cell")
cell:addClass("sv-topband-cell")


local wrap = cell:tag("div")
-- Nested table (this is what your new CSS targets)
wrap:addClass("sv-skill-topband")
local inner = cell:tag("table")
inner:addClass("sv-topband-table")


local left = wrap:tag("div"):addClass("sv-topband-left")
local tr = inner:tag("tr")
left:wikitext(levelUI or "")


local right = wrap:tag("div"):addClass("sv-topband-right")
if levelUI and typeUI then
right:wikitext(typeUI or "")
tr:tag("td"):wikitext(levelUI):done()
 
tr:tag("td"):wikitext(typeUI):done()
-- Styling is handled via Common.css (recommended).
elseif levelUI then
tr:tag("td"):attr("colspan", 2):wikitext(levelUI):done()
else
tr:tag("td"):attr("colspan", 2):wikitext(typeUI):done()
end
end
end


Line 951: Line 953:


------------------------------------------------------------------
------------------------------------------------------------------
-- NEW: Unified top band (replaces "General" + "Type" section bars)
-- Unified top band (Level Select left, Type list right)
------------------------------------------------------------------
------------------------------------------------------------------
local typeUI = buildTypeListUI(rec.Type or {})
local levelUI = buildLevelSelectUI(level, maxLevel)
local levelUI = buildLevelSelectUI(level, maxLevel)
local typeUI  = buildTypeTableUI(rec.Type or {})
addTopBand(root, levelUI, typeUI)
addTopBand(root, levelUI, typeUI)


------------------------------------------------------------------
------------------------------------------------------------------
-- Users (kept as rows, but no "General" header)
-- Users (kept as rows; hidden on lists or skill page)
------------------------------------------------------------------
------------------------------------------------------------------
if showUsers then
if showUsers then
Line 1,013: Line 1,015:
addRow(root, "Resource Cost", formatResourceCost(mech["Resource Cost"], maxLevel, level))
addRow(root, "Resource Cost", formatResourceCost(mech["Resource Cost"], maxLevel, level))
addRow(root, "Combo", formatCombo(mech.Combo))
addRow(root, "Combo", formatCombo(mech.Combo))
-- UPDATED CALL: pass maxLevel + level
addRow(root, "Special Mechanics", formatMechanicEffects(mech.Effects, maxLevel, level))
addRow(root, "Special Mechanics", formatMechanicEffects(mech.Effects, maxLevel, level))
end
end