缺氧 wiki 编辑团队提示:注册账号并登录后体验更佳,且可通过参数设置定制优化您的浏览体验!

该站点为镜像站点,如果你想帮助这个由玩家志愿编辑的 wiki 站点,请前往原站点参与编辑,
同时欢迎加入编辑讨论群 851803695 与其他编辑者一起参与建设!

全站通知:

模块:表格/流星雨季

来自缺氧WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

此模块的文档可以在模块:表格/流星雨季/doc创建

-- Module:表格/流星雨季节
local p = {}
local fstr = mw.ustring.format -- shortcut for formattig a string
local getArgs = require('Module:Dev/Arguments').getArgs
local tb = require([[Module:表格]])
local po = require([[Module:Po]]).po
local utils = require([[Module:Utils]])
local sData = mw.loadData([[Module:Data/GameplaySeasons]])
local mData = mw.loadData([[Module:Data/MeteorShowers]])

local exception_name = {
    MeteorShowerIronEvent = po("STRINGS.UI.SPACEDESTINATIONS.CLUSTERMAPMETEORSHOWERS.IRON.NAME"),
    MeteorShowerGoldEvent = po("STRINGS.UI.SPACEDESTINATIONS.CLUSTERMAPMETEORSHOWERS.GOLD.NAME"),
    MeteorShowerCopperEvent = po("STRINGS.UI.SPACEDESTINATIONS.CLUSTERMAPMETEORSHOWERS.COPPER.NAME"),
    MeteorShowerFullereneEvent = po("STRINGS.ELEMENTS.FULLERENE.NAME") ..
        po("STRINGS.UI.FRONTEND.CUSTOMGAMESETTINGSSCREEN.SETTINGS.METEORSHOWERS.NAME")
}

local function getMeteorName(itemCode, meteorId)
    if itemCode ~= nil then
        return po(itemCode)
    end
    local name = exception_name[meteorId]
    if name ~= nil then
        return name
    end
    return nil
end

local DLCS = {
    [""] = 1,
    ["EXPANSION1_ID"] = 2,
    ["DLC2_ID"] = 3
}

-- test by: = p._main({})
function p._main(seasonData)
    local out = {}

    table.insert(out, fstr("<code>%s</code>", seasonData.Id))
    local dlcIcon = utils.DLC_ICONS[seasonData.dlcId]
    table.insert(out, dlcIcon ~= nil and dlcIcon or "")
    table.insert(out, seasonData.period)
    if seasonData.eventIds ~= nil then
        local events = {}
        for _, eventId in ipairs(seasonData.eventIds) do
            local meteorData = mData[eventId]
            if meteorData ~= nil then
                table.insert(events, {
                    name = getMeteorName(meteorData.clusterMapName, meteorData.id),
                    id = eventId
                })
            end
        end
        table.insert(out, table.concat(utils.map(events, function(event)
            if event.name ~= nil then
                return fstr("{{物品|%s}}", event.name)
            else
                return ""
            end
        end), "<br/>"))
        table.insert(out, table.concat(utils.map(events, function(event)
            if event.id == nil then
                return ""
            else
                return fstr("<code>%s</code>", event.id)
            end
        end), "<br/>"))
    else
        table.insert(out, "")
        table.insert(out, "")
    end
    if seasonData.clusterTravelDuration ~= nil then
        table.insert(out, seasonData.clusterTravelDuration == -1 and "无" or
            utils.float2str(seasonData.clusterTravelDuration / 600))
    else
        table.insert(out, "无")
    end
    table.insert(out, seasonData.affectedByDifficultySettings == true and "是" or "否")
    return out
end

-- test by: = p.main({})
-- test by: = p.main({dlc=""})
-- test by: = p.main({dlc="EXPANSION1_ID"})
function p.main(frame)
    local args = getArgs(frame)
    local infos = {}

    local dlc = args.dlc
    for seasonId, seasonData in pairs(sData) do
        if dlc == nil or (dlc ~= nil and dlc == seasonData.dlcId) then
            local info = p._main(seasonData)
            table.insert(infos, {
                info = info,
                dlc = seasonData.dlcId
            })
        end
    end
    table.sort(infos, function(a, b)
        if DLCS[a.dlc] == nil then
            return true
        elseif DLCS[b.dlc] == nil then
            return false
        else
            return DLCS[a.dlc] < DLCS[b.dlc]
        end
    end)
    infos = utils.map(infos, function(info)
        return info.info
    end)

    -- mw.logObject(infos)
    return tb.table(infos, args)
end

return p