卡厄思
梦
境
菜单
首页
回到首页
WIKI工具
全站样式
全站JS
修改导航栏
测试
沙盒
可视化管理器
战斗员管理器
卡牌管理器
伙伴管理器
装备管理器
词典管理器
图鉴
战斗员
伙伴
装备
怪物卡牌
中立卡牌
词典
小工具
配队模拟器
节奏榜生成器
搜索
链入页面
相关更改
特殊页面
页面信息
最近更改
登录
模块
查看“︁装备”︁的源代码
←
模块:装备
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local p = {} -- 兼容不同命名空间的 data 路径 local function loadData() local paths = { '模块:装备/data', 'Module:装备/data' } for _, path in ipairs(paths) do local ok, d = pcall(mw.loadData, path) if ok and type(d) == 'table' then return d end end return {} end local data = loadData() -- 更稳健的参数获取(优先使用 Arguments 模块,兼容中英文命名) local function getArgsCompat(frame) local tryModules = { 'Module:Arguments', '模块:Arguments' } for _, m in ipairs(tryModules) do local ok, Arguments = pcall(require, m) if ok and type(Arguments) == 'table' and type(Arguments.getArgs) == 'function' then return Arguments.getArgs(frame, { parentOnly = false }) end end -- 回退:合并 frame.args 与 parent.args 到普通表 local args = {} local fa = frame.args or {} for k, v in pairs(fa) do args[k] = v end local parent = frame:getParent() if parent and parent.args then for k, v in pairs(parent.args) do if args[k] == nil then args[k] = v end end end return args end local function clampLevel(level) level = tonumber(level) if not level then return 1 end if level < 1 then return 1 end if level > 5 then return 5 end return level end local function starIcon(level) level = clampLevel(level) return string.format("icon_star_rating_%d.png", level) end local function sanitizeId(s) s = tostring(s or '') s = mw.text.trim(s) s = mw.ustring.gsub(s, "%s+", "_") s = mw.ustring.gsub(s, "[%[%]{}()%c%p]", "_") return s end function p.render(frame) local args = getArgsCompat(frame) -- 支持多种参数名(中文键使用方括号访问,避免语法错误) local name = args.name or args['名称'] or args[1] local level = clampLevel(args.level or args.lv or args['等级'] or args[2] or 1) if not name or name == '' then return "<span style='color:red'>[装备] 数据未找到:未指定</span>" end if not data[name] then return string.format("<span style='color:red'>[装备] 数据未找到:%s</span>", mw.text.encode(name)) end local eq = data[name] local base = eq.base or {} local rarity = base.rarity or "蓝" local art = base.art or "" local typ = base.type or "武器" local valueType = base.value_type or "" local lvlKey = tostring(level) local lvl = eq[lvlKey] or {} local value = lvl.value or "" local desc = lvl.desc_global or "" local modalId = "equip_modal_" .. sanitizeId(name) .. "_" .. tostring(level) local root = mw.html.create('span') -- 使用锚点触发 :target 显示弹窗(无 JS 也可用) local link = root:tag('a') :attr('href', '#' .. modalId) :attr('style', 'text-decoration:none;') -- 卡片 local card = link:tag('div') :addClass('equip-card') :attr('data-equip-id', modalId) :attr('style', 'position: relative; display: inline-block; width:150px; height: 230px; cursor: pointer;') card:tag('div') :attr('style', 'position: absolute; top: 0px; left: 0px;') :wikitext(string.format('[[File:bg_equipment_rarity_%s.png|150px|link=]]', rarity)) card:tag('div') :attr('style', 'position: absolute; top: 43px; left: 13px;') :wikitext(string.format('[[File:%s|124px|link=]]', art)) card:tag('div') :attr('style', 'position: absolute; bottom: 5px; left: 5px; width: 140px; height: 35px; background-color: rgba(0,0,0,0.5); border-radius: 0px 0px 8px 8px') card:tag('div') :attr('style', 'position: absolute; bottom: 10px; left: 20px; ') :wikitext(string.format('[[File:%s|link=]]', starIcon(level))) card:tag('div') :attr('style', 'position: absolute; top: 0px; left: 0px;') :wikitext('[[File:equipment_顶层蒙版.png|150px|link=]]') -- 弹窗容器(遮罩) local modalContainer = root:tag('div') :addClass('equip-modal-container') :attr('id', modalId) -- 弹窗内容 local modal = modalContainer:tag('div') :addClass('equip-modal') :attr('style', 'position: relative; display: inline-block; width:368px; height: 335px; background-color: #343434; border-radius: 9px') modal:tag('div') :attr('style', 'position: absolute; top: 0px; left: 0px;') :wikitext(string.format('[[File:bg_collection_rarity_%s.png|link=]]', rarity)) modal:tag('div') :attr('style', 'position: absolute; top: 40px; left: 128px;') :wikitext(string.format('[[File:%s|124px|link=]]', art)) modal:tag('div') :attr('style', 'position: absolute; top: 167px; left: 0px; width: 368px; height: 35px; background-color: rgba(0,0,0,0.5); border-radius: 0px 0px 8px 8px') modal:tag('div') :attr('style', 'position: absolute; top: 173px; left: 128px; ') :wikitext(string.format('[[File:%s|link=]]', starIcon(level))) modal:tag('div') :attr('style', 'position: absolute; top: 205px; left: 5px; color: white') :wikitext(string.format('[[File:icon_equip_%s_%s.png|25px|link=]]', typ, rarity)) modal:tag('div') :attr('style', 'position: absolute; top: 209px; left: 33px; color: white') :wikitext(name) modal:tag('div') :attr('style', 'position: absolute; top: 235px; left: 9px; width: 350px; height: 35px; background-color: rgba(255,255,255,0.3); border-radius: 2px') modal:tag('div') :attr('style', 'position: absolute; top: 242px; left: 14px; color: white') :wikitext(valueType) modal:tag('div') :attr('style', 'position: absolute; top: 242px; right: 14px; color: white') :wikitext(tostring(value)) modal:tag('div') :attr('style', 'position: absolute; top: 277px; left: 10px; color: white') :wikitext(desc) -- 关闭按钮(锚点,回到无 hash) modal:tag('a') :addClass('equip-modal-close') :attr('href', '#') :attr('title', '关闭') :attr('style', 'position: absolute; top: 6px; right: 10px; color: white; font-size: 20px; line-height: 20px; cursor: pointer; text-decoration:none;') :wikitext('×') return tostring(root) end return p
该页面使用的模板:
模块:装备/doc
(
查看源代码
)
返回
模块:装备
。