蒙纳多研究本部
菜单
导航
首页
最近更改
随机页面
翻译查询
乐园数据管理室
送行者的收集手册
搜索
链入页面
相关更改
特殊页面
页面信息
最近更改
帮助
登录
模块
查看“︁Gem”︁的源代码
←
模块:Gem
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您必须确认您的电子邮件地址才能编辑页面。请通过
参数设置
设置并确认您的电子邮件地址。
您可以查看和复制此页面的源代码。
-- 模块: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%" local function rangeText(s, key) local lo = num(s["lower_" .. key]) local hi = num(s["upper_" .. key]) local pct = num(s["percent_" .. key]) == 1 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 = num(s.percent_S) == 1 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 = num(s.percent_S) == 1 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
该页面使用的模板:
模块:Gem/doc
(
查看源代码
)
返回
模块:Gem
。