模块:装备
来自卡厄思梦境WIKI
此模块的文档可以在模块:装备/doc创建
local equipment = {}
local data = mw.loadData('Module:装备/data')
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 ""
-- 星级图片
local star_img = "icon_star_rating_" .. star .. ".png"
-- >>> 主卡片HTML + 弹窗HTML 一起输出 <<<
local html = [=[
<div class="equipment-wrapper" style="display: inline-block; position: relative;">
<!-- 小卡片 -->
<div class="equipment-card" style="position: relative; width:150px; height:230px; cursor: pointer;" onclick="openEquipPopup(this)">
<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 class="equipment-popup" style="display:none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 9999; width:368px; height:335px; background-color:#343434; border-radius:9px; padding:0; box-shadow:0 0 20px rgba(0,0,0,0.8);">
<div style="position: absolute; top: 8px; right: 12px; color:white; font-size:20px; font-weight:bold; cursor:pointer;" onclick="closeEquipPopup(this)">×</div>
<div style="position: absolute; top: 0px; left: 0px;">[[File:bg_collection_rarity_]=] .. rarity .. [=[.png|link=]]</div>
<div style="position: absolute; top: 40px; left: 128px;">[[File:]=] .. art .. [=[|124px|link=]]</div>
<div 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"></div>
<div style="position: absolute; top: 173px; left: 128px;">[[File:]=] .. star_img .. [=[|link=]]</div>
<div style="position: absolute; top: 205px; left: 5px; color: white;">[[File:]=] .. type_icon .. [=[|25px|link=]]</div>
<div style="position: absolute; top: 209px; left: 33px; color: white; font-weight:bold;">]=] .. name .. [=[</div>
<div style="position: absolute; top: 235px; left: 9px; width: 350px; height: 35px; background-color: rgba(255,255,255,0.3); border-radius: 2px"></div>
<div style="position: absolute; top: 242px; left: 14px; color: white; font-size:14px;">]=] .. value_type .. [=[</div>
<div style="position: absolute; top: 242px; right: 14px; color: white; font-size:14px; font-weight:bold;">]=] .. value .. [=[</div>
<div style="position: absolute; top: 277px; left: 10px; width: 348px; color: white; font-size:13px; line-height:1.4; word-wrap:break-word;">]=] .. desc .. [=[</div>
</div>
<!-- 遮罩层 -->
<div class="equipment-overlay" style="display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.7); z-index:9998;" onclick="closeEquipPopup(this)"></div>
</div>
]=]
return html
end
equipment.main = equipment.show
return equipment