模块:NewCraftsCN

来自Mooncell - 玩家共同构筑的FGO中文Wiki
跳到导航 跳到搜索

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

local p = {}

function p.show(frame)
    local function ce_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_ce0 = tonumber(frame:callParserFunction{name = '#lst:Mooncell:Gameinfo/国服/灵基一览', args = {'cnprevces'}})
    local n_ce1 = tonumber(frame:callParserFunction{name = '#lst:Mooncell:Gameinfo/国服/灵基一览', args = {'cnces'}})
    local ex_ce0 = ce_list('cnprevskippedces')
    local ex_ce1 = ce_list('cnskippedces')
    local in_ce0 = ce_list('cnprevaheadces')
    local in_ce1 = ce_list('cnaheadces')

    local id_display = {}
    for id = n_ce0 + 1, n_ce1 do
        if not (ex_ce1[id] or in_ce0[id]) then table.insert(id_display, id) end
    end
    for id, _ in pairs(in_ce1) do
        if id > n_ce1 and (not in_ce0[id]) then table.insert(id_display, id) end
    end
    for id, _ in pairs(ex_ce0) do
        if id <= n_ce0 and (not ex_ce1[id]) then table.insert(id_display, id) end
    end

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

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

    return table.concat(ces)
end

return p