卡厄思
梦
境
菜单
首页
回到首页
WIKI工具
全站样式
全站JS
修改导航栏
测试
沙盒
可视化管理器
战斗员管理器
卡牌管理器
伙伴管理器
装备管理器
词典管理器
图鉴
战斗员
伙伴
装备
怪物卡牌
中立卡牌
词典
小工具
配队模拟器
节奏榜生成器
搜索
链入页面
相关更改
特殊页面
页面信息
最近更改
登录
模块
查看“︁配队/卡牌”︁的源代码
←
模块:配队/卡牌
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local p = {} -- 引用卡牌模块 local cardModule = require('Module:卡牌') local getArgs = require('Module:Arguments').getArgs -- 小尺寸卡牌渲染 local function renderSmallCard(moduleName, cardName) if not moduleName or moduleName == "" or not cardName or cardName == "" then return "" end -- 调用卡牌模块的main函数 local success, result = pcall(function() local frame = mw.getCurrentFrame() local childFrame = frame:newChild{ args = {moduleName, cardName} } return cardModule.main(childFrame) end) if success then return result else return '<span style="color:red;">错误: ' .. tostring(result) .. '</span>' end end -- 主函数:显示战斗员的配队卡牌 function p.main(frame) local args = getArgs(frame) local combatantName = args[1] or mw.title.getCurrentTitle().text -- 查询战斗员页面 local query = { '[[分类:战斗员]]', '[[' .. combatantName .. ']]', '?自我意识技能', '?起始卡牌_1', '?起始卡牌_2', '?起始卡牌_3', '?起始卡牌_4', '?独特卡牌_1', '?独特卡牌_2', '?独特卡牌_3', '?独特卡牌_4', limit = 1 } local results = mw.smw.ask(query) if not results or #results == 0 then return '<span style="color:red;">未找到战斗员数据</span>' end local data = results[1] local html = {} -- 开始容器 table.insert(html, '<div class="combatant-cards" style="margin: 20px 0;">') -- 标题 table.insert(html, '<h3 style="margin-bottom: 15px;">配队卡牌</h3>') -- 卡牌容器 table.insert(html, '<div style="display:flex;gap:15px;flex-wrap:wrap;align-items:flex-start;">') -- 按顺序处理卡牌 local cardOrder = { {field = '自我意识技能', label = '自我意识技能'}, {field = '起始卡牌_1', label = '起始卡牌1'}, {field = '起始卡牌_2', label = '起始卡牌2'}, {field = '起始卡牌_3', label = '起始卡牌3'}, {field = '起始卡牌_4', label = '起始卡牌4'}, {field = '独特卡牌_1', label = '独特卡牌1'}, {field = '独特卡牌_2', label = '独特卡牌2'}, {field = '独特卡牌_3', label = '独特卡牌3'}, {field = '独特卡牌_4', label = '独特卡牌4'} } for _, cardInfo in ipairs(cardOrder) do local cardValue = data[cardInfo.field] if cardValue and cardValue ~= "" then -- 解析卡牌值(格式:模块名|卡牌名) local moduleName, cardName = string.match(tostring(cardValue), "^([^|]+)|(.+)$") if moduleName and cardName then -- 添加卡牌标签 table.insert(html, '<div class="card-slot" style="display:flex;flex-direction:column;align-items:center;">') table.insert(html, '<div style="font-size:12px;color:#666;margin-bottom:5px;">' .. cardInfo.label .. '</div>') -- 渲染小尺寸卡牌 table.insert(html, renderSmallCard(moduleName, cardName)) table.insert(html, '</div>') end end end table.insert(html, '</div>') -- 结束卡牌容器 table.insert(html, '</div>') -- 结束主容器 return table.concat(html, '') end -- 批量显示多个战斗员的配队 function p.batch(frame) local args = getArgs(frame) local html = {} -- 查询所有战斗员 local query = { '[[分类:战斗员]]', '?自我意识技能', '?起始卡牌_1', '?起始卡牌_2', '?起始卡牌_3', '?起始卡牌_4', '?独特卡牌_1', '?独特卡牌_2', '?独特卡牌_3', '?独特卡牌_4', limit = args.limit or 50 } local results = mw.smw.ask(query) if not results or #results == 0 then return '<span style="color:red;">未找到战斗员数据</span>' end table.insert(html, '<div class="all-combatant-cards">') for _, combatant in ipairs(results) do local combatantName = combatant[1] and string.match(combatant[1], "([^#]+)") or "未知战斗员" -- 检查是否有任何卡牌数据 local hasCards = false local fields = {'自我意识技能', '起始卡牌_1', '起始卡牌_2', '起始卡牌_3', '起始卡牌_4', '独特卡牌_1', '独特卡牌_2', '独特卡牌_3', '独特卡牌_4'} for _, field in ipairs(fields) do if combatant[field] and combatant[field] ~= "" then hasCards = true break end end if hasCards then table.insert(html, '<div style="margin-bottom:30px;border:1px solid #ddd;padding:15px;border-radius:5px;">') table.insert(html, '<h3>' .. combatantName .. '</h3>') -- 调用main函数显示该战斗员的卡牌 local childFrame = mw.getCurrentFrame():newChild{ args = {combatantName} } table.insert(html, p.main(childFrame)) table.insert(html, '</div>') end end table.insert(html, '</div>') return table.concat(html, '') end -- 显示指定战斗员列表的配队 function p.list(frame) local args = getArgs(frame) local html = {} table.insert(html, '<div class="combatant-cards-list">') -- 遍历所有参数,每个参数是一个战斗员名称 for i = 1, 20 do -- 最多支持20个战斗员 local combatantName = args[i] if combatantName and combatantName ~= "" then local childFrame = mw.getCurrentFrame():newChild{ args = {combatantName} } table.insert(html, '<div style="margin-bottom:20px;">') table.insert(html, '<h4>' .. combatantName .. '</h4>') table.insert(html, p.main(childFrame)) table.insert(html, '</div>') end end table.insert(html, '</div>') return table.concat(html, '') end return p
该页面使用的模板:
模块:配队/卡牌/doc
(
查看源代码
)
返回
模块:配队/卡牌
。