模块:NewCodesCN

可在模块:NewCodesCN/doc创建此模块的帮助文档

local p = {}

function p.show(frame)
    local function cc_list(key)
        local res_list = {}
        local list0 = mw.text.split(frame:callParserFunction{name = '#lst:Mooncell:Gameinfo/国服/灵基一览', args = {key}}, ',', true)
        for _, id in ipairs(list0) do
            if id ~= "" then
                res_list[tonumber(id)] = true
            end
        end
        return res_list
    end

    local n_cc0 = tonumber(frame:callParserFunction{name = '#lst:Mooncell:Gameinfo/国服/灵基一览', args = {'cnprevccs'}})
    local n_cc1 = tonumber(frame:callParserFunction{name = '#lst:Mooncell:Gameinfo/国服/灵基一览', args = {'cnccs'}})
    local ex_cc0 = cc_list('cnprevskippedccs')
    local ex_cc1 = cc_list('cnskippedccs')
    local in_cc0 = cc_list('cnprevaheadccs')
    local in_cc1 = cc_list('cnaheadccs')

    local id_display = {}
    for id = n_cc0 + 1, n_cc1 do
        if not ex_cc1[id] then table.insert(id_display, id) end
    end
    for id, _ in pairs(in_cc1) do
        if id > n_cc1 and (not in_cc0[id]) then table.insert(id_display, id) end
    end
    for id, _ in pairs(ex_cc0) do
        if id <= n_cc0 and (not ex_cc1[id]) then table.insert(id_display, id) end
    end

    local t_name = (#id_display > 7) and "新增卡牌/纹章小图标" or "新增卡牌/纹章大图标"
    table.sort(id_display)

    local ccs = {}
    for _, id in ipairs(id_display) do
        local link = frame:callParserFunction{name = '#ask:[[分类:指令纹章图鉴]][[纹章序号::' .. id .. ']]', args = {link = 'none'}}
        table.insert(ccs, frame:expandTemplate{ title = t_name, args = { link, id } })
    end

    return table.concat(ccs)
end

return p