卡厄思
梦
境
菜单
首页
回到首页
WIKI工具
全站样式
全站JS
修改导航栏
测试
沙盒
可视化管理器
战斗员管理器
卡牌管理器
伙伴管理器
装备管理器
词典管理器
图鉴
战斗员
伙伴
装备
怪物卡牌
中立卡牌
词典
小工具
配队模拟器
节奏榜生成器
搜索
链入页面
相关更改
特殊页面
页面信息
最近更改
登录
模块
查看“︁模块:中立&怪物卡牌灵光一闪”︁的源代码
←
模块:中立&怪物卡牌灵光一闪
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local p = {} local data = mw.loadData("模块:中立&怪物卡牌灵光一闪/data") -- 分割字符串函数 local function split(str, delimiter) if not str or str == "" then return {} end local result = {} for match in (str .. delimiter):gmatch("(.-)" .. delimiter) do table.insert(result, match) end return result end -- 检查是否包含某个值 local function contains(str, value) if not str or str == "" then return false end local items = split(str, "、") for _, item in ipairs(items) do if item == value then return true end end return false end -- 检查费用范围 local function checkCost(item, minCost, maxCost) if minCost and tonumber(minCost) then if item.cost_min < tonumber(minCost) then return false end end if maxCost and tonumber(maxCost) then if item.cost_max > tonumber(maxCost) then return false end end return true end -- 筛选函数 local function filterData(filters) local result = {} for _, item in ipairs(data) do local match = true -- 筛选类型 if filters.type and filters.type ~= "" and filters.type ~= "全部" then if not item.type or not contains(item.type, filters.type) then match = false end end -- 筛选包含机制 if match and filters.dict_include and filters.dict_include ~= "" and filters.dict_include ~= "全部" then if not item.dict_include or not contains(item.dict_include, filters.dict_include) then match = false end end -- 筛选排除机制 if match and filters.dict_exclude and filters.dict_exclude ~= "" and filters.dict_exclude ~= "全部" then if not item.dict_exclude or not contains(item.dict_exclude, filters.dict_exclude) then match = false end end -- 筛选职业 if match and filters.class and filters.class ~= "" and filters.class ~= "全部" then if not item.class or not contains(item.class, filters.class) then match = false end end -- 筛选费用 if match then if not checkCost(item, filters.cost_min, filters.cost_max) then match = false end end if match then table.insert(result, item) end end return result end -- 生成唯一ID local function generateId() return tostring(os.time()) .. math.random(1000, 9999) end -- 主函数 function p.show(frame) -- 获取URL参数 local request = mw.getCurrentFrame():getParent() or frame local args = request.args -- 获取筛选参数 local filters = { type = args.type or "", dict_include = args.dict_include or "", dict_exclude = args.dict_exclude or "", class = args.class or "", cost_min = args.cost_min or "", cost_max = args.cost_max or "" } -- 筛选数据 local filteredData = filterData(filters) -- 构建输出 local output = "" -- 添加筛选表单Widget output = output .. "== 筛选条件 ==\n" local widgetId = generateId() output = output .. frame:extensionTag{ name = 'widget', args = { id = widgetId }, content = 'CardFilter' } -- 显示当前筛选信息 local hasFilter = false local filterInfo = "" if filters.type and filters.type ~= "" then filterInfo = filterInfo .. "* 类型: " .. filters.type .. "\n" hasFilter = true end if filters.dict_include and filters.dict_include ~= "" then filterInfo = filterInfo .. "* 包含机制: " .. filters.dict_include .. "\n" hasFilter = true end if filters.dict_exclude and filters.dict_exclude ~= "" then filterInfo = filterInfo .. "* 排除机制: " .. filters.dict_exclude .. "\n" hasFilter = true end if filters.class and filters.class ~= "" then filterInfo = filterInfo .. "* 职业: " .. filters.class .. "\n" hasFilter = true end if filters.cost_min and filters.cost_min ~= "" then filterInfo = filterInfo .. "* 最低费用: " .. filters.cost_min .. "\n" hasFilter = true end if filters.cost_max and filters.cost_max ~= "" then filterInfo = filterInfo .. "* 最高费用: " .. filters.cost_max .. "\n" hasFilter = true end if hasFilter then output = output .. "\n=== 当前筛选 ===\n" .. filterInfo end -- 构建表格 output = output .. "\n== 结果 ==\n" local html = mw.html.create('table') html:addClass('wikitable sortable') -- 表头 local headerRow = html:tag('tr') headerRow:tag('th'):wikitext('描述') headerRow:tag('th'):wikitext('最低费用') headerRow:tag('th'):wikitext('最高费用') headerRow:tag('th'):wikitext('类型') headerRow:tag('th'):wikitext('包含机制') headerRow:tag('th'):wikitext('排除机制') headerRow:tag('th'):wikitext('职业') -- 数据行 for _, item in ipairs(filteredData) do local row = html:tag('tr') row:tag('td'):wikitext(item.desc_global or "") row:tag('td'):wikitext(tostring(item.cost_min)) row:tag('td'):wikitext(tostring(item.cost_max)) row:tag('td'):wikitext(item.type or "") row:tag('td'):wikitext(item.dict_include or "") row:tag('td'):wikitext(item.dict_exclude or "") row:tag('td'):wikitext(item.class or "") end output = output .. tostring(html) output = output .. "\n\n''共 " .. #filteredData .. " 条结果''" return output end return p
该页面使用的模板:
模块:中立&怪物卡牌灵光一闪/doc
(
查看源代码
)
返回
模块:中立&怪物卡牌灵光一闪
。