Module:GameSkills: Difference between revisions
From SpiritVale Wiki
More actions
No edit summary |
No edit summary |
||
| Line 878: | Line 878: | ||
end | end | ||
-- ------------------------------------------------------------ | |||
-- Module 1 – Level Selector | |||
-- ------------------------------------------------------------ | |||
local function buildModuleLevelSelector(level, maxLevel) | local function buildModuleLevelSelector(level, maxLevel) | ||
local inner = mw.html.create("div") | local inner = mw.html.create("div") | ||
| Line 902: | Line 905: | ||
end | end | ||
-- ------------------------------------------------------------ | |||
-- Module 2 – Skill Type | |||
-- ------------------------------------------------------------ | |||
local function buildModuleSkillType(typeBlock) | local function buildModuleSkillType(typeBlock) | ||
typeBlock = (type(typeBlock) == "table") and typeBlock or {} | typeBlock = (type(typeBlock) == "table") and typeBlock or {} | ||
| Line 918: | Line 924: | ||
return nil | return nil | ||
end | end | ||
local grid = mw.html.create("div") | |||
grid:addClass("sv-type-grid") | |||
local added = false | |||
local function addChunk(label, rawVal) | |||
local v = valName(rawVal) | |||
if not v or v == "" then | |||
return | |||
end | |||
added = true | |||
local chunk = grid:tag("div"):addClass("sv-type-chunk") | |||
chunk:tag("div"):addClass("sv-type-label"):wikitext(mw.text.nowiki(label)) | |||
chunk:tag("div"):addClass("sv-type-value"):wikitext(mw.text.nowiki(v)) | |||
end | |||
addChunk("Damage", typeBlock.Damage or typeBlock["Damage Type"]) | |||
addChunk("Element", typeBlock.Element or typeBlock["Element Type"]) | |||
addChunk("Target", typeBlock.Target or typeBlock["Target Type"]) | |||
addChunk("Cast", typeBlock.Cast or typeBlock["Cast Type"]) | |||
local body = added and tostring(grid) or "" | |||
return moduleBox(2, "module-skill-type", body, false) | |||
end | |||
-- ============================================================ | -- ============================================================ | ||
-- Module 3 – Skill Source (Source + Scaling) | -- Module 3 – Skill Source (Source + Scaling) | ||
-- | -- RULE: If BOTH source + scaling are missing, return nil (slot stays empty) | ||
-- ============================================================ | -- ============================================================ | ||
| Line 928: | Line 958: | ||
-- "1% Vitality" | -- "1% Vitality" | ||
-- "8% Intelligence" | -- "8% Intelligence" | ||
local function formatScalingCompactLines(scaling | local function formatScalingCompactLines(scaling) | ||
if type(scaling) ~= "table" then | if type(scaling) ~= "table" then | ||
return {} | return {} | ||
| Line 961: | Line 991: | ||
end | end | ||
-- Prefer the “current level value” ( | -- Prefer the “current level value” (dynSpan when we have series lists) | ||
local function sourceValueForLevel(src, maxLevel, level) | local function sourceValueForLevel(src, maxLevel, level) | ||
if type(src) ~= "table" then | if type(src) ~= "table" then | ||
| Line 986: | Line 1,015: | ||
end | end | ||
-- Fallback: | -- Fallback: may display as "X (Per Level: Y)" if not expanded by wikiprep | ||
return valuePairDynamicValueOnly(src, maxLevel, level) | return valuePairDynamicValueOnly(src, maxLevel, level) | ||
end | end | ||
-- Legacy (pre-Source) damage entry: compute | -- Legacy (pre-Source) damage entry: compute % at current level | ||
local function legacyPercentAtLevel(entry, level) | local function legacyPercentAtLevel(entry, level) | ||
if type(entry) ~= "table" then | if type(entry) ~= "table" then | ||
| Line 1,002: | Line 1,030: | ||
local perN = toNum(perRaw) | local perN = toNum(perRaw) | ||
-- If Per Level exists, level 1 | -- If Per Level exists, level 1 shows at least per*1 even when base is 0/missing. | ||
if perN ~= nil and perN ~= 0 then | if perN ~= nil and perN ~= 0 then | ||
local total = (baseN or 0) + (perN * level) | local total = (baseN or 0) + (perN * level) | ||
| Line 1,041: | Line 1,069: | ||
local flat = dmg["Flat Damage"] | local flat = dmg["Flat Damage"] | ||
-- priority: Main Damage > Reflect > Flat | -- priority: Main Damage > Reflect > Flat | ||
if type(main) == "table" and #main > 0 then | if type(main) == "table" and #main > 0 then | ||
-- pick first non-healing if possible | -- pick first non-healing if possible | ||
| Line 1,055: | Line 1,083: | ||
if type(pick) == "table" then | if type(pick) == "table" then | ||
sourceKind = (pick.Type == "Healing") and "Healing" or "Damage" | sourceKind = (pick.Type == "Healing") and "Healing" or "Damage" | ||
local v = legacyPercentAtLevel(pick, level) | |||
sourceVal = v and mw.text.nowiki(v) or nil | |||
end | end | ||
elseif type(refl) == "table" and #refl > 0 and type(refl[1]) == "table" then | elseif type(refl) == "table" and #refl > 0 and type(refl[1]) == "table" then | ||
sourceKind = "Reflect" | sourceKind = "Reflect" | ||
local v = legacyPercentAtLevel(refl[1], level) | |||
sourceVal = v and mw.text.nowiki(v) or nil | |||
elseif type(flat) == "table" and #flat > 0 and type(flat[1]) == "table" then | elseif type(flat) == "table" and #flat > 0 and type(flat[1]) == "table" then | ||
sourceKind = "Flat" | sourceKind = "Flat" | ||
local v = legacyPercentAtLevel(flat[1], level) | |||
sourceVal = v and mw.text.nowiki(v) or nil | |||
end | end | ||
end | end | ||
| Line 1,105: | Line 1,136: | ||
return moduleBox(3, extra, tostring(wrap), false) | return moduleBox(3, extra, tostring(wrap), false) | ||
end | end | ||
| Line 1,142: | Line 1,148: | ||
grid:wikitext(buildModuleLevelSelector(level, maxLevel)) | grid:wikitext(buildModuleLevelSelector(level, maxLevel)) | ||
grid:wikitext(buildModuleSkillType(rec.Type or {})) | grid:wikitext(buildModuleSkillType(rec.Type or {})) | ||
local m3 = buildModuleSkillSource(rec, level, maxLevel) | |||
grid:wikitext(m3 or buildEmptyModule(3)) | |||
grid:wikitext(buildEmptyModule(4)) | grid:wikitext(buildEmptyModule(4)) | ||