Module:GameSkills: Difference between revisions
From SpiritVale Wiki
More actions
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 | -- Row 1: Module 1 + Module 2 → Icon + Name, Skill Type strip | ||
-- 2) | -- Row 2: Module 3 + Module 4 → Description (Module 3), open slot (Module 4) | ||
-- 3 | -- 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 | -- Module row order (see layout notes above). | ||
local MODULE_SLOT_ASSIGNMENT = { | |||
[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 | local MODULE_GRID_PAIRS = { | ||
{ 3, 4 }, | |||
{ 5, 6 }, | |||
{ 7, 8 }, | |||
} | } | ||
| 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") | |||
box:addClass("hero-bar-module") | |||
box:addClass("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") | |||
box:addClass("hero-module") | |||
box:addClass("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 = | 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 = | 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 | ||
-- | -- buildModuleGridUI: build the lower module rows (Modules 3–8, 3 rows). | ||
local function | 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 | 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( | 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 | ||
-- | -- addModuleGridRow: add the lower module grid into the infobox table. | ||
local function | local function addModuleGridRow(tbl, modulesUI) | ||
if not modulesUI or modulesUI == "" then | |||
return | |||
end | |||
local row = tbl:tag("tr") | |||
row:addClass("hero-modules-row") | |||
local cell = row:tag("td") | |||
cell:attr("colspan", 2) | |||
cell:addClass("hero-modules-cell") | |||
cell:wikitext(modulesUI) | |||
end | end | ||
| Line 1,774: | Line 1,806: | ||
end | end | ||
-- Module 1–2 (Icon + Skill Type) | |||
local heroRow = root:tag("tr") | |||
heroRow:addClass("spiritvale-infobox-main") | |||
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:addClass("sv-hero-title-cell") | |||
heroCell:wikitext(buildHeroBarUI(rec, ctx)) | |||
-- Module grid (rows 2–4) | |||
addModuleGridRow(root, buildModuleGridUI(rec, ctx)) | |||
-- Users (hide on direct skill page) | -- Users (hide on direct skill page) | ||