Module:GameInfo/Skills: Difference between revisions
From SpiritVale Wiki
More actions
No edit summary Tags: Mobile edit Mobile web edit |
No edit summary Tags: Mobile edit Mobile web edit |
||
| Line 13: | Line 13: | ||
-- - Meta row has its own icon slot, so meta labels always use noicon=1. | -- - Meta row has its own icon slot, so meta labels always use noicon=1. | ||
-- - Keyword pills also use noicon=1 (no extra icons in pills). | -- - Keyword pills also use noicon=1 (no extra icons in pills). | ||
-- - Stat scaling (skill_scaling.stat_scaling) renders WITH icons. | |||
local p = {} | local p = {} | ||
| Line 478: | Line 479: | ||
end | end | ||
local function _build_scaling_top(scaling, level) | -- UPDATED: supports stat_scaling (Defs WITH icons) + fallback scaling_lines | ||
local function _build_scaling_top(frame, scaling, level) | |||
scaling = _safe_tbl(scaling) | scaling = _safe_tbl(scaling) | ||
| Line 495: | Line 497: | ||
local col = grid:tag("div"):addClass("sv-scaling-col sv-scaling-col--scaling") | local col = grid:tag("div"):addClass("sv-scaling-col sv-scaling-col--scaling") | ||
local list = col:tag("div"):addClass("sv-scaling-list") | local list = col:tag("div"):addClass("sv-scaling-list") | ||
-- Schema 2: render stat_scaling with icons | |||
for _, it in ipairs(_safe_tbl(scaling.stat_scaling)) do | |||
it = _safe_tbl(it) | |||
local tok = _safe_str(it.stat_wt or it.stat or "", "") | |||
local val = _safe_str(it.value or "", "") | |||
if tok ~= "" and val ~= "" then | |||
local item = list:tag("div"):addClass("sv-scaling-item sv-scaling-item--stat") | |||
local wt = _render_def_token(frame, tok, false) or mw.text.nowiki(tok) | |||
item:tag("span"):addClass("sv-scale-stat"):wikitext(wt) | |||
item:tag("span"):addClass("sv-scale-val"):wikitext(mw.text.nowiki(val)) | |||
end | |||
end | |||
-- Schema 1 / legacy: render scaling_lines after (if any) | |||
for _, ln in ipairs(_safe_tbl(scaling.scaling_lines)) do | for _, ln in ipairs(_safe_tbl(scaling.scaling_lines)) do | ||
local item = list:tag("div"):addClass("sv-scaling-item") | local item = list:tag("div"):addClass("sv-scaling-item") | ||
| Line 532: | Line 549: | ||
return root | return root | ||
end | end | ||
-- (unchanged) _build_tabs(...) is below in your module | |||
-- (unchanged) _adapt_schema2(...) is below in your module, except stat_scaling handling updated | |||
local function _build_tabs(frame, root_id, tabs_obj, level) | local function _build_tabs(frame, root_id, tabs_obj, level) | ||
-- unchanged from your version | |||
tabs_obj = _safe_tbl(tabs_obj) | tabs_obj = _safe_tbl(tabs_obj) | ||
| Line 762: | Line 783: | ||
local oc = _safe_tbl(lv.overcap) | local oc = _safe_tbl(lv.overcap) | ||
local max = _to_int(oc.max, natural) | local max = _to_int(oc.max, natural) | ||
out.level = { base_max = natural, max = max } | out.level = { base_max = natural, max = max } | ||
end | end | ||
| Line 772: | Line 792: | ||
out.scaling_top = { | out.scaling_top = { | ||
damage = _safe_tbl(_safe_tbl(sc.damage).value), | damage = _safe_tbl(_safe_tbl(sc.damage).value), | ||
scaling_lines = {}, | scaling_lines = {}, -- legacy fallback | ||
} | } | ||
-- UPDATED: preserve structured stat_scaling for icon rendering | |||
out.scaling_top.stat_scaling = {} | |||
for _, it in ipairs(_safe_tbl(sc.stat_scaling)) do | for _, it in ipairs(_safe_tbl(sc.stat_scaling)) do | ||
it = _safe_tbl(it) | it = _safe_tbl(it) | ||
local tok = _safe_str(it.stat_wt, "") | local tok = _safe_str(it.stat_wt or it.stat or "", "") | ||
local val = _safe_str(it.value, "") | local val = _safe_str(it.value or "", "") | ||
if tok ~= "" and val ~= "" then | if tok ~= "" and val ~= "" then | ||
table.insert(out.scaling_top.stat_scaling, { stat_wt = tok, value = val }) | |||
end | end | ||
end | end | ||
if # | if #out.scaling_top.stat_scaling == 0 then | ||
out.scaling_top.stat_scaling = nil | |||
end | end | ||
| Line 880: | Line 897: | ||
box.bottom:node(level_panel) | box.bottom:node(level_panel) | ||
box.bottom:node(_build_scaling_top(payload.scaling_top, actual_default)) | box.bottom:node(_build_scaling_top(frame, payload.scaling_top, actual_default)) | ||
box.bottom:node(_build_core_stats(payload.core_stats, actual_default)) | box.bottom:node(_build_core_stats(payload.core_stats, actual_default)) | ||
box.bottom:node(_build_tabs(frame, root_id, payload.tabs, actual_default)) | box.bottom:node(_build_tabs(frame, root_id, payload.tabs, actual_default)) | ||