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 3: Line 3:
-- Phase 6.5+ (Plug-in Slot Architecture)
-- Phase 6.5+ (Plug-in Slot Architecture)
--
--
-- Layout:
-- Layout (Module 1–8):
--  1) hero-title-bar        (TOP BAR, 2 slots: herobar 1..2)
--  Row 1: Module 1 + Module 2   → Icon + Name, Skill Type strip
--  2) hero-description-bar  (description strip)
--  Row 2: Module 3 + Module 4  → Description (Module 3), open slot (Module 4)
--  3) hero-modules row      (4 slots: hero-module-1..4)
--  Row 3: Module 5 + Module 6  → Source Types, Quick Stats
--   Row 4: Module 7 + Module 8  → Special Mechanics, Level Selector
--
--
-- Requires Common.js:
-- Requires Common.js:
Line 475: Line 476:
----------------------------------------------------------------------
----------------------------------------------------------------------


local HERO_BAR_SLOT_ASSIGNMENT = {
-- Module row order (see layout notes above).
[1] = "IconName",
local MODULE_SLOT_ASSIGNMENT = {
[2] = "SkillType", -- Damage/Element/Hits/Target/Cast/Combo strip
        [1] = "IconName",
        [2] = "SkillType", -- Damage/Element/Hits/Target/Cast/Combo strip
        [3] = "Description",
        [4] = nil, -- placeholder / intentionally open
        [5] = "SourceType",
        [6] = "QuickStats",
        [7] = "SpecialMechanics",
        [8] = "LevelSelector",
}
}


local HERO_MODULE_SLOT_ASSIGNMENT = {
local MODULE_GRID_PAIRS = {
[1] = "SourceType",
        { 3, 4 },
[2] = "QuickStats",
        { 5, 6 },
[3] = "SpecialMechanics",
        { 7, 8 },
[4] = "LevelSelector",
}
}


Line 493: Line 500:
-- heroBarBox: wrapper for hero-bar slot modules.
-- heroBarBox: wrapper for hero-bar slot modules.
local function heroBarBox(slot, extraClasses, innerHtml, isEmpty)
local function heroBarBox(slot, extraClasses, innerHtml, isEmpty)
local box = mw.html.create("div")
        local box = mw.html.create("div")
box:addClass("hero-bar-module")
        box:addClass("hero-bar-module")
box:addClass("hero-bar-module-" .. tostring(slot))
        box:addClass("hero-bar-module-" .. tostring(slot))
box:attr("data-hero-bar-module", tostring(slot))
        box:addClass("sv-module-slot")
        box:addClass("sv-module-slot-" .. tostring(slot))
        box:attr("data-hero-bar-module", tostring(slot))
        box:attr("data-module-slot", tostring(slot))


if slot == 2 then
if slot == 2 then
Line 524: Line 534:
-- moduleBox: wrapper for hero-module (2x2 grid) slot modules.
-- moduleBox: wrapper for hero-module (2x2 grid) slot modules.
local function moduleBox(slot, extraClasses, innerHtml, isEmpty)
local function moduleBox(slot, extraClasses, innerHtml, isEmpty)
local box = mw.html.create("div")
        local box = mw.html.create("div")
box:addClass("hero-module")
        box:addClass("hero-module")
box:addClass("hero-module-" .. tostring(slot))
        box:addClass("hero-module-" .. tostring(slot))
box:attr("data-hero-module", tostring(slot))
        box:addClass("sv-module-slot")
        box:addClass("sv-module-slot-" .. tostring(slot))
        box:attr("data-hero-module", tostring(slot))
        box:attr("data-module-slot", tostring(slot))


if extraClasses then
if extraClasses then
Line 1,103: Line 1,116:
classes = "module-skill-type",
classes = "module-skill-type",
}
}
end
function PLUGINS.Description(rec, ctx)
        local desc = trim(rec.Description)
        if not desc then
                return nil
        end
        local wrapper = mw.html.create("div")
        wrapper:addClass("sv-module-description")
        wrapper:wikitext(string.format("''%s''", desc))
        return {
                inner = tostring(wrapper),
                classes = "module-description",
        }
end
end


Line 1,589: Line 1,618:
-- renderHeroBarSlot: render a hero-bar slot by plugin assignment.
-- renderHeroBarSlot: render a hero-bar slot by plugin assignment.
local function renderHeroBarSlot(slotIndex, rec, ctx)
local function renderHeroBarSlot(slotIndex, rec, ctx)
         local pluginName = HERO_BAR_SLOT_ASSIGNMENT[slotIndex]
         local pluginName = MODULE_SLOT_ASSIGNMENT[slotIndex]
         if not pluginName then
         if not pluginName then
                 return heroBarBox(slotIndex, nil, "", true)
                 return heroBarBox(slotIndex, nil, "", true)
Line 1,645: Line 1,674:
-- renderModuleSlot: render a hero-module slot by plugin assignment.
-- renderModuleSlot: render a hero-module slot by plugin assignment.
local function renderModuleSlot(slotIndex, rec, ctx)
local function renderModuleSlot(slotIndex, rec, ctx)
         local pluginName = HERO_MODULE_SLOT_ASSIGNMENT[slotIndex]
         local pluginName = MODULE_SLOT_ASSIGNMENT[slotIndex]
         if not pluginName then
         if not pluginName then
                 return nil
                 return nil
Line 1,674: Line 1,703:
end
end


-- buildHeroModulesUI: build the 2x2 module grid row (4 slots).
-- buildModuleGridUI: build the lower module rows (Modules 3–8, 3 rows).
local function buildHeroModulesUI(rec, ctx)
local function buildModuleGridUI(rec, ctx)
         local grid = mw.html.create("div")
         local grid = mw.html.create("div")
         grid:addClass("hero-modules-grid")
         grid:addClass("hero-modules-grid")
        grid:addClass("sv-modules-grid")


         local slots = {}
         local slots = {}
         for slot = 1, 4 do
         for _, pair in ipairs(MODULE_GRID_PAIRS) do
                 slots[slot] = renderModuleSlot(slot, rec, ctx)
                 for _, slot in ipairs(pair) do
                        slots[slot] = renderModuleSlot(slot, rec, ctx)
                end
         end
         end


         local hasModules = false
         local hasModules = false
         for _, pair in ipairs({ { 1, 2 }, { 3, 4 } }) do
         for _, pair in ipairs(MODULE_GRID_PAIRS) do
                 local left  = slots[pair[1]]
                 local left  = slots[pair[1]]
                 local right = slots[pair[2]]
                 local right = slots[pair[2]]
Line 1,710: Line 1,742:
end
end


-- addHeroModulesRow: add the hero-modules row into the infobox table.
-- addModuleGridRow: add the lower module grid into the infobox table.
local function addHeroModulesRow(tbl, modulesUI)
local function addModuleGridRow(tbl, modulesUI)
if not modulesUI or modulesUI == "" then
        if not modulesUI or modulesUI == "" then
return
                return
end
        end


local row = tbl:tag("tr")
        local row = tbl:tag("tr")
row:addClass("hero-modules-row")
        row:addClass("hero-modules-row")


local cell = row:tag("td")
        local cell = row:tag("td")
cell:attr("colspan", 2)
        cell:attr("colspan", 2)
cell:addClass("hero-modules-cell")
        cell:addClass("hero-modules-cell")
cell:wikitext(modulesUI)
        cell:wikitext(modulesUI)
end
end


Line 1,774: Line 1,806:
end
end


local desc  = rec.Description or ""
        -- Module 1–2 (Icon + Skill Type)
 
        local heroRow = root:tag("tr")
-- Hero Title Bar
        heroRow:addClass("spiritvale-infobox-main")
local heroRow = root:tag("tr")
        heroRow:addClass("sv-hero-title-row")
heroRow:addClass("spiritvale-infobox-main")
        heroRow:addClass("hero-title-bar")
heroRow:addClass("sv-hero-title-row")
heroRow:addClass("hero-title-bar")


local heroCell = heroRow:tag("th")
local heroCell = heroRow:tag("th")
heroCell:attr("colspan", 2)
        heroCell:attr("colspan", 2)
heroCell:addClass("sv-hero-title-cell")
        heroCell:addClass("sv-hero-title-cell")
heroCell:wikitext(buildHeroBarUI(rec, ctx))
        heroCell:wikitext(buildHeroBarUI(rec, ctx))
 
-- Description Bar
if desc ~= "" then
local descRow = root:tag("tr")
descRow:addClass("spiritvale-infobox-main")
descRow:addClass("sv-hero-desc-row")
descRow:addClass("hero-description-bar")
 
local descCell = descRow:tag("td")
descCell:attr("colspan", 2)
descCell:addClass("sv-hero-desc-cell")
 
local descInner = descCell:tag("div")
descInner:addClass("spiritvale-infobox-main-right-inner")
 
descInner:tag("div")
:addClass("spiritvale-infobox-description")
:wikitext(string.format("''%s''", desc))
end


-- Modules row
        -- Module grid (rows 2–4)
addHeroModulesRow(root, buildHeroModulesUI(rec, ctx))
        addModuleGridRow(root, buildModuleGridUI(rec, ctx))


-- Users (hide on direct skill page)
-- Users (hide on direct skill page)