模块

模块:中立&怪物卡牌灵光一闪

来自卡厄思梦境WIKI

律Rhyme留言 | 贡献2025年11月3日 (一) 13:36的版本
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

此模块的文档可以在模块:中立&怪物卡牌灵光一闪/doc创建

local p = {}
local data = mw.loadData("模块:中立&怪物卡牌灵光一闪/data")

-- 主函数
function p.show(frame)
    local output = ""
    
    -- 构建包含所有数据的表格
    output = output .. "=== 结果 ===\n"
    local html = mw.html.create('table')
    html:addClass('wikitable sortable')
    html:attr('id', 'card-results-table')
    
    -- 表头
    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(data) do
        local row = html:tag('tr')
        row:attr('data-type', item.type or "")
        row:attr('data-dict-include', item.dict_include or "")
        row:attr('data-dict-exclude', item.dict_exclude or "")
        row:attr('data-class', item.class or "")
        row:attr('data-cost-min', tostring(item.cost_min))
        row:attr('data-cost-max', tostring(item.cost_max))
        
        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<div id='result-count'>''共 " .. #data .. " 条结果''</div>"
    
    return output
end

return p