缺氧 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 mData = mw.loadData([[Module:Data/MeteorShowers]])
local cData = mw.loadData([[Module:Data/Comets]])

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

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

    local name = getMeteorName(itemData.clusterMapName, itemData.id)
    name = name == nil and "无译名" or fstr("{{物品|%s}}", name)
    table.insert(out, fstr("%s", name))
    table.insert(out, fstr("<code>%s</code>", itemData.id))
    if itemData.duration ~= nil then
        table.insert(out, utils.float2str(itemData.duration / 600))
    else
        table.insert(out, "")
    end
    if itemData.bombardmentInfo ~= nil then
        local max = 0
        for _, bombInfo in ipairs(itemData.bombardmentInfo) do
            max = max + bombInfo.weight
        end
        local bombardmentInfo = table.concat(utils.map(itemData.bombardmentInfo, function(bombInfo)
            local cometId = bombInfo.prefab
            local cometData = cData[cometId]
            if cometData ~= nil then
                if cometData.Name ~= nil then
                    local name = po(cometData.Name)
                    if not utils.isDefaultT(cometData.Name, name) then
                        return fstr("{{物品|%s}}", name)
                    end
                end
            end
            return fstr("<code>%s</code>", cometId)
        end), "<br/>")
        table.insert(out, bombardmentInfo)
        local bombardmentInfoWeight = table.concat(utils.map(itemData.bombardmentInfo, function(bombInfo)
            return fstr('<abbr title = "%s/%s">%s%%</abbr>', utils.float2str(bombInfo.weight), utils.float2str(max),
                utils.float2str(bombInfo.weight / (max == 0 and 1 or max) * 100))
        end), "<br/>")
        table.insert(out, bombardmentInfoWeight)
    else
        table.insert(out, "")
        table.insert(out, "")
    end
    if itemData.secondsBombardmentOn ~= nil then
        if itemData.secondsBombardmentOn.min >= itemData.duration then
            table.insert(out, "全事件周期")
        else
            table.insert(out, fstr("%s ↔ %s", utils.float2str(itemData.secondsBombardmentOn.min),
                utils.float2str(itemData.secondsBombardmentOn.max)))
        end
    else
        table.insert(out, "")
    end
    if itemData.secondsBombardmentOff ~= nil then
        if itemData.secondsBombardmentOff.min >= itemData.duration then
            table.insert(out, "全事件周期")
        else
            table.insert(out, fstr("%s ↔ %s", utils.float2str(itemData.secondsBombardmentOff.min),
                utils.float2str(itemData.secondsBombardmentOff.max)))
        end
    else
        table.insert(out, "")
    end
    if itemData.secondsPerMeteor ~= nil then
        table.insert(out, utils.float2str(itemData.secondsPerMeteor))
    else
        table.insert(out, "")
    end
    if itemData.affectedByDifficulty ~= nil then
        table.insert(out, itemData.affectedByDifficulty == true and "是" or "否")
    else
        table.insert(out, "")
    end

    return out
end

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

    local dlc = args.dlc
    for meteorId, meteorData in pairs(mData) do
        local info = p._main(meteorData)
        table.insert(infos, info)
    end

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

return p