Gem:修订间差异
来自蒙纳多研究本部
创建页面,内容为“-- 模块:Gem —— 宝珠渲染层(列表 / infobox) -- 用法: -- {{#invoke:Gem|list|slot=shared}} 共用宝珠列表(本模块首发目标) -- {{#invoke:Gem|list|slot=weapon}} 武器宝珠列表(复用同管线) -- {{#invoke:Gem|list|slot=armor}} 防具宝珠列表(复用同管线) -- {{#invoke:Gem|infobox|id=1}} 单宝珠信息框 -- 表头用语取自游戏内官方 UI 文本(MNU_item_ms):武器·防具共用…” |
无编辑摘要 |
||
| (未显示同一用户的1个中间版本) | |||
| 第1行: | 第1行: | ||
-- 模块:Gem —— 宝珠渲染层(列表 / infobox) | -- 模块:Gem —— 宝珠渲染层(列表 / infobox) | ||
-- 用法: | -- 用法: | ||
-- {{#invoke:Gem|list|slot=shared}} | -- {{#invoke:Gem|list|slot=shared}} 武器防具共用宝珠 | ||
-- {{#invoke:Gem|list|slot=weapon}} | -- {{#invoke:Gem|list|slot=weapon}} 武器专用宝珠 | ||
-- {{#invoke:Gem|list|slot=armor}} | -- {{#invoke:Gem|list|slot=armor}} 防具专用宝珠 | ||
-- {{#invoke:Gem|infobox|id=1}} 单宝珠信息框 | -- {{#invoke:Gem|infobox|id=1}} 单宝珠信息框 | ||
-- | -- 格式对齐站内旧页面《武器防具共用宝珠》(人力维护版): | ||
-- 等级列 I~VI 对应数据六档锚点 E/D/C/B/A/S(游戏内共用宝珠只有 VI 档,没有 X) | |||
-- 颜色列 = atr_type 映射(4红 5深蓝 6黄 7浅蓝 8绿 9橙) | |||
-- 类型列 = category 映射(1能力 4支援 5场景 2攻击 3防御) | |||
-- 最大值列 = max 字段 | |||
-- 名称列 = skilllist.name(线上 xbdb 已解析为中文短名) | |||
local p = {} | local p = {} | ||
| 第11行: | 第16行: | ||
local gemData = require("Module:GemData") | local gemData = require("Module:GemData") | ||
local gemSMW = require("Module:GemSMW") | local gemSMW = require("Module:GemSMW") | ||
local SLOTS = { | local SLOTS = { | ||
shared = { attach = 0, title = " | shared = { attach = 0, title = "武器防具共用宝珠" }, | ||
weapon = { attach = 1, title = "武器专用宝珠" }, | weapon = { attach = 1, title = "武器专用宝珠" }, | ||
armor = { attach = 2, title = "防具专用宝珠" }, | armor = { attach = 2, title = "防具专用宝珠" }, | ||
} | } | ||
local | -- 六档锚点(游戏内宝珠等级 I~VI,对应 BTL_skilllist 的 E/D/C/B/A/S) | ||
local ROMAN6 = { "Ⅰ", "Ⅱ", "Ⅲ", "Ⅳ", "Ⅴ", "Ⅵ" } | |||
local KEYS6 = { "E", "D", "C", "B", "A", "S" } | |||
-- 颜色映射(atr_type,原页面人力标注 → 数据字段反推) | |||
local ATR_COLOR = { | |||
[4] = "红", [5] = "深蓝", [6] = "黄", [7] = "浅蓝", [8] = "绿", [9] = "橙", | |||
} | |||
-- 类型映射(category:1能力 2攻击 3防御 4支援 5场景 6成长/获得) | |||
local CATEGORY_TYPE = { | |||
[1] = "能力", [2] = "攻击", [3] = "防御", [4] = "支援", [5] = "场景", [6] = "能力", | |||
} | |||
-- rvs_type:1=永续型(被动常驻)3=永续型 0/2=其他 | |||
-- 原页面「永续型」列:数据 rvs_type=1 或 3 都是常驻型;0=发动型(如无法战斗抗性97) | |||
local RVS_LABEL = { | |||
[1] = "永续型", [3] = "永续型", [0] = "发动型", [2] = "发动型", | |||
} | |||
local function num(v) | local function num(v) | ||
| 第26行: | 第48行: | ||
end | end | ||
-- | -- 区间文本:"5-10",百分比档 "5-10%"(单位判定用 GemData.hasPercent,percent_* 字段不可用) | ||
local function | local function rangeText(s, key) | ||
local lo = num(s["lower_" .. key]) | |||
local hi = num(s["upper_" .. key]) | |||
local pct = gemData.hasPercent(s) and "%" or "" | |||
return lo .. "-" .. hi .. pct | |||
end | |||
-- 效果说明:caption 去掉【永续型】前缀、$1 置空(说明列不填数值) | |||
local function effectText(s) | |||
local cap = s.rvs_caption or "" | |||
cap = cap:gsub("^【[^】]*】", ""):gsub("%$1", "") | |||
return mw.text.trim(cap) | |||
end | end | ||
-- ====== | -- ====== 列表(格式对齐旧页面) ====== | ||
function p.list(frame) | function p.list(frame) | ||
local args = require("Module:Arguments").getArgs(frame) | local args = require("Module:Arguments").getArgs(frame) | ||
| 第49行: | 第80行: | ||
gemSMW.annotateAll(gems) | gemSMW.annotateAll(gems) | ||
-- | -- 旧页面格式:宝珠名称 | 颜色 | Ⅰ~Ⅵ 六档区间 | 最大值 | 类型 | 说明 | ||
-- (原页面的「永续型」列与「类型」列拆开;rvs_type 已统一为永续型,可从效果文字判断) | |||
local out = {} | local out = {} | ||
out[#out + 1] = ' | out[#out + 1] = '{| class="wikitable"' | ||
out[#out + 1] = ' | out[#out + 1] = '|-' | ||
out[#out + 1] = '! 宝珠名称 !! 颜色 !! colspan=6 | 效果数值 !! 最大值 !! 类型 !! 说明' | |||
out[#out + 1] = '|-' | |||
out[#out + 1] = '! !! !! ' .. table.concat(ROMAN6, " !! ") .. ' !! !! !!' | |||
for _, gem in ipairs(gems) do | for _, gem in ipairs(gems) do | ||
local s = gem.data | local s = gem.data | ||
local | local color = ATR_COLOR[num(s.atr_type)] or "?" | ||
local | local cat = CATEGORY_TYPE[num(s.category)] or "?" | ||
local | local ranges = {} | ||
-- | for _, key in ipairs(KEYS6) do | ||
local | ranges[#ranges + 1] = rangeText(s, key) | ||
end | |||
-- 最大值:max 字段 + 百分比跟随 S 档 | |||
local maxPct = gemData.hasPercent(s) and "%" or "" | |||
out[#out + 1] = '|-' | |||
out[#out + 1] = string.format( | out[#out + 1] = string.format( | ||
' | '| %s || %s || %s || %s || %s || %s', | ||
name | s.name or ("宝珠#" .. gem.id), | ||
color, | |||
table.concat(ranges, " || "), | |||
num(s.max) .. maxPct, | |||
cat, | |||
effectText(s) | |||
) | ) | ||
end | end | ||
out[#out + 1] = ' | out[#out + 1] = '|}' | ||
out[#out + 1] = string.format('<!-- 共 %d 条 | 数据: bdat_common.BTL_skilllist attach=%d | out[#out + 1] = string.format('<!-- 共 %d 条 | 数据: bdat_common.BTL_skilllist attach=%d -->', #gems, slot.attach) | ||
return table.concat(out, "\n") | return table.concat(out, "\n") | ||
| 第87行: | 第130行: | ||
end | end | ||
-- SMW | -- SMW 注解 | ||
gemSMW.annotate(id, s) | gemSMW.annotate(id, s) | ||
local color = ATR_COLOR[num(s.atr_type)] or "?" | |||
local cat = CATEGORY_TYPE[num(s.category)] or "?" | |||
local out = {} | local out = {} | ||
out[#out + 1] = '{| class="wikitable" style="float:right; width: | out[#out + 1] = '{| class="wikitable" style="float:right; width:300px; margin-left:1em"' | ||
out[#out + 1] = '|+ ' .. (s. | out[#out + 1] = '|+ ' .. (s.name or ("宝珠#" .. id)) | ||
out[#out + 1] = '|-' | out[#out + 1] = '|-' | ||
out[#out + 1] = '! | out[#out + 1] = '! 颜色 || ' .. color | ||
out[#out + 1] = '| ' .. | out[#out + 1] = '|-' | ||
out[#out + 1] = '! 类型 || ' .. cat | |||
out[#out + 1] = '|-' | |||
out[#out + 1] = '! 说明 || ' .. effectText(s) | |||
out[#out + 1] = '|-' | out[#out + 1] = '|-' | ||
out[#out + 1] = '! colspan=2 | | out[#out + 1] = '! colspan=2 | 效果数值(Ⅰ~Ⅵ)' | ||
for | for i, key in ipairs(KEYS6) do | ||
out[#out + 1] = '|-' | out[#out + 1] = '|-' | ||
out[#out + 1] = '! ' .. | out[#out + 1] = '! ' .. ROMAN6[i] | ||
out[#out + 1] = '| ' .. | out[#out + 1] = '| ' .. rangeText(s, key) | ||
end | end | ||
local maxPct = gemData.hasPercent(s) and "%" or "" | |||
out[#out + 1] = '|-' | |||
out[#out + 1] = '! 最大值 || ' .. num(s.max) .. maxPct | |||
out[#out + 1] = '|}' | out[#out + 1] = '|}' | ||
2026年10月13日 (二) 21:50的最新版本
此模块的文档可以在模块:Gem/doc创建
-- 模块:Gem —— 宝珠渲染层(列表 / infobox)
-- 用法:
-- {{#invoke:Gem|list|slot=shared}} 武器防具共用宝珠
-- {{#invoke:Gem|list|slot=weapon}} 武器专用宝珠
-- {{#invoke:Gem|list|slot=armor}} 防具专用宝珠
-- {{#invoke:Gem|infobox|id=1}} 单宝珠信息框
-- 格式对齐站内旧页面《武器防具共用宝珠》(人力维护版):
-- 等级列 I~VI 对应数据六档锚点 E/D/C/B/A/S(游戏内共用宝珠只有 VI 档,没有 X)
-- 颜色列 = atr_type 映射(4红 5深蓝 6黄 7浅蓝 8绿 9橙)
-- 类型列 = category 映射(1能力 4支援 5场景 2攻击 3防御)
-- 最大值列 = max 字段
-- 名称列 = skilllist.name(线上 xbdb 已解析为中文短名)
local p = {}
local gemData = require("Module:GemData")
local gemSMW = require("Module:GemSMW")
local SLOTS = {
shared = { attach = 0, title = "武器防具共用宝珠" },
weapon = { attach = 1, title = "武器专用宝珠" },
armor = { attach = 2, title = "防具专用宝珠" },
}
-- 六档锚点(游戏内宝珠等级 I~VI,对应 BTL_skilllist 的 E/D/C/B/A/S)
local ROMAN6 = { "Ⅰ", "Ⅱ", "Ⅲ", "Ⅳ", "Ⅴ", "Ⅵ" }
local KEYS6 = { "E", "D", "C", "B", "A", "S" }
-- 颜色映射(atr_type,原页面人力标注 → 数据字段反推)
local ATR_COLOR = {
[4] = "红", [5] = "深蓝", [6] = "黄", [7] = "浅蓝", [8] = "绿", [9] = "橙",
}
-- 类型映射(category:1能力 2攻击 3防御 4支援 5场景 6成长/获得)
local CATEGORY_TYPE = {
[1] = "能力", [2] = "攻击", [3] = "防御", [4] = "支援", [5] = "场景", [6] = "能力",
}
-- rvs_type:1=永续型(被动常驻)3=永续型 0/2=其他
-- 原页面「永续型」列:数据 rvs_type=1 或 3 都是常驻型;0=发动型(如无法战斗抗性97)
local RVS_LABEL = {
[1] = "永续型", [3] = "永续型", [0] = "发动型", [2] = "发动型",
}
local function num(v)
if v == nil then return 0 end
return tonumber(v) or 0
end
-- 区间文本:"5-10",百分比档 "5-10%"(单位判定用 GemData.hasPercent,percent_* 字段不可用)
local function rangeText(s, key)
local lo = num(s["lower_" .. key])
local hi = num(s["upper_" .. key])
local pct = gemData.hasPercent(s) and "%" or ""
return lo .. "-" .. hi .. pct
end
-- 效果说明:caption 去掉【永续型】前缀、$1 置空(说明列不填数值)
local function effectText(s)
local cap = s.rvs_caption or ""
cap = cap:gsub("^【[^】]*】", ""):gsub("%$1", "")
return mw.text.trim(cap)
end
-- ====== 列表(格式对齐旧页面) ======
function p.list(frame)
local args = require("Module:Arguments").getArgs(frame)
local slotKey = args.slot or "shared"
local slot = SLOTS[slotKey]
if not slot then
return '<strong class="error">未知 slot:' .. mw.text.nowiki(slotKey) .. '</strong>'
end
local gems = gemData.gemsByAttach(slot.attach)
if #gems == 0 then
return '<strong class="error">GemData 未返回任何 ' .. slot.title .. '(xbdb 不可达或数据为空)</strong>'
end
-- SMW 注解:列表渲染即建档(同解析内去重,见 GemSMW)
gemSMW.annotateAll(gems)
-- 旧页面格式:宝珠名称 | 颜色 | Ⅰ~Ⅵ 六档区间 | 最大值 | 类型 | 说明
-- (原页面的「永续型」列与「类型」列拆开;rvs_type 已统一为永续型,可从效果文字判断)
local out = {}
out[#out + 1] = '{| class="wikitable"'
out[#out + 1] = '|-'
out[#out + 1] = '! 宝珠名称 !! 颜色 !! colspan=6 | 效果数值 !! 最大值 !! 类型 !! 说明'
out[#out + 1] = '|-'
out[#out + 1] = '! !! !! ' .. table.concat(ROMAN6, " !! ") .. ' !! !! !!'
for _, gem in ipairs(gems) do
local s = gem.data
local color = ATR_COLOR[num(s.atr_type)] or "?"
local cat = CATEGORY_TYPE[num(s.category)] or "?"
local ranges = {}
for _, key in ipairs(KEYS6) do
ranges[#ranges + 1] = rangeText(s, key)
end
-- 最大值:max 字段 + 百分比跟随 S 档
local maxPct = gemData.hasPercent(s) and "%" or ""
out[#out + 1] = '|-'
out[#out + 1] = string.format(
'| %s || %s || %s || %s || %s || %s',
s.name or ("宝珠#" .. gem.id),
color,
table.concat(ranges, " || "),
num(s.max) .. maxPct,
cat,
effectText(s)
)
end
out[#out + 1] = '|}'
out[#out + 1] = string.format('<!-- 共 %d 条 | 数据: bdat_common.BTL_skilllist attach=%d -->', #gems, slot.attach)
return table.concat(out, "\n")
end
-- ====== infobox ======
function p.infobox(frame)
local args = require("Module:Arguments").getArgs(frame)
local id = tonumber(args.id)
if not id then
return '<strong class="error">缺少 id 参数</strong>'
end
local s = gemData.getGem(id)
if not s then
return '<strong class="error">宝珠 #' .. id .. ' 不存在或不是可装备宝珠</strong>'
end
-- SMW 注解
gemSMW.annotate(id, s)
local color = ATR_COLOR[num(s.atr_type)] or "?"
local cat = CATEGORY_TYPE[num(s.category)] or "?"
local out = {}
out[#out + 1] = '{| class="wikitable" style="float:right; width:300px; margin-left:1em"'
out[#out + 1] = '|+ ' .. (s.name or ("宝珠#" .. id))
out[#out + 1] = '|-'
out[#out + 1] = '! 颜色 || ' .. color
out[#out + 1] = '|-'
out[#out + 1] = '! 类型 || ' .. cat
out[#out + 1] = '|-'
out[#out + 1] = '! 说明 || ' .. effectText(s)
out[#out + 1] = '|-'
out[#out + 1] = '! colspan=2 | 效果数值(Ⅰ~Ⅵ)'
for i, key in ipairs(KEYS6) do
out[#out + 1] = '|-'
out[#out + 1] = '! ' .. ROMAN6[i]
out[#out + 1] = '| ' .. rangeText(s, key)
end
local maxPct = gemData.hasPercent(s) and "%" or ""
out[#out + 1] = '|-'
out[#out + 1] = '! 最大值 || ' .. num(s.max) .. maxPct
out[#out + 1] = '|}'
return table.concat(out, "\n")
end
p.SLOTS = SLOTS
return p