装备:修订间差异
来自卡厄思梦境WIKI
无编辑摘要 |
无编辑摘要 |
||
| 第1行: | 第1行: | ||
local | local equipment = {} | ||
local data = mw.loadData('Module:装备/data') -- 从数据模块加载 | |||
-- | -- 主函数,接收参数:装备名, 星级(默认1) | ||
function equipment.show(frame) | |||
local args = frame.args | |||
local name = args[1] or args.name | |||
function | local star = tonumber(args[2] or args.star or 1) | ||
if not name then return '<span style="color:red">未指定装备名</span>' end | |||
if | local eq = data[name] | ||
if not eq then return '<span style="color:red">装备「' .. name .. '」不存在</span>' end | |||
local | local base = eq.base | ||
if not | local level = eq[tostring(star)] or eq["1"] | ||
if not level then star = 1; level = eq["1"] end | |||
local base = | local art = base.art or "relic_placeholder.png" | ||
local | local rarity = base.rarity or "蓝" | ||
local type_icon = "icon_equip_" .. (base.type or "武器") .. "_" .. rarity .. ".png" | |||
local value_type = base.value_type or "属性" | |||
local value = level.value or 0 | |||
local desc = level.desc_global or "" | |||
-- 生成星级图标(1~5星) | |||
local star_img = "icon_star_rating_" .. star .. ".png" | |||
-- | -- 主卡片HTML(点击触发弹窗) | ||
local html = [=[ | local html = [=[ | ||
<div class="equipment-card" data-equip-name="]=] .. | <div class="equipment-card" data-equip-name="]=] .. mw.text.encode(name) .. [=[" data-star="]=] .. star .. [=["> | ||
<div style="position: relative; display: inline-block; width:150px; height: 230px;"> | |||
<div style="position: absolute; top: 0px; left: 0px;">[[File:bg_equipment_rarity_]=] .. rarity .. [=[.png|150px|link=]]</div> | |||
<div style="position: absolute; top: 43px; left: 13px;">[[File:]=] .. art .. [=[|124px|link=]]</div> | |||
<div 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"></div> | |||
<div style="position: absolute; bottom: 10px; left: 20px;">[[File:]=] .. star_img .. [=[|link=]]</div> | |||
<div style="position: absolute; top: 0px; left: 0px;">[[File:equipment_顶层蒙版.png|150px|link=]]</div> | |||
</div> | |||
</div> | </div> | ||
]=] | ]=] | ||
return html | return html | ||
end | end | ||
equipment.main = equipment.show -- 兼容 #invoke:装备 | |||
-- | |||
return | return equipment | ||
2025年10月17日 (五) 16:00的版本
此模块的文档可以在模块:装备/doc创建
local equipment = {}
local data = mw.loadData('Module:装备/data') -- 从数据模块加载
-- 主函数,接收参数:装备名, 星级(默认1)
function equipment.show(frame)
local args = frame.args
local name = args[1] or args.name
local star = tonumber(args[2] or args.star or 1)
if not name then return '<span style="color:red">未指定装备名</span>' end
local eq = data[name]
if not eq then return '<span style="color:red">装备「' .. name .. '」不存在</span>' end
local base = eq.base
local level = eq[tostring(star)] or eq["1"]
if not level then star = 1; level = eq["1"] end
local art = base.art or "relic_placeholder.png"
local rarity = base.rarity or "蓝"
local type_icon = "icon_equip_" .. (base.type or "武器") .. "_" .. rarity .. ".png"
local value_type = base.value_type or "属性"
local value = level.value or 0
local desc = level.desc_global or ""
-- 生成星级图标(1~5星)
local star_img = "icon_star_rating_" .. star .. ".png"
-- 主卡片HTML(点击触发弹窗)
local html = [=[
<div class="equipment-card" data-equip-name="]=] .. mw.text.encode(name) .. [=[" data-star="]=] .. star .. [=[">
<div style="position: relative; display: inline-block; width:150px; height: 230px;">
<div style="position: absolute; top: 0px; left: 0px;">[[File:bg_equipment_rarity_]=] .. rarity .. [=[.png|150px|link=]]</div>
<div style="position: absolute; top: 43px; left: 13px;">[[File:]=] .. art .. [=[|124px|link=]]</div>
<div 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"></div>
<div style="position: absolute; bottom: 10px; left: 20px;">[[File:]=] .. star_img .. [=[|link=]]</div>
<div style="position: absolute; top: 0px; left: 0px;">[[File:equipment_顶层蒙版.png|150px|link=]]</div>
</div>
</div>
]=]
return html
end
equipment.main = equipment.show -- 兼容 #invoke:装备
return equipment