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

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

全站通知:

模块:间歇泉信息框

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

用于模板:Template:间歇泉信息框。 视图模块:Module:信息框/间歇泉。 数据模块:Module:Data/Geysers



-- Module:间歇泉信息框
local p = {}
local fstr = mw.ustring.format

local utils = require("Module:Utils")
local k0 = utils.K0
local po = require([[Module:Po]]).po
local i18ncr = require([[Module:I18n]]).loadMessages([[Module:I18n/Creatures]])
local infobox = require([[Module:信息框/间歇泉]])
local getArgs = require([[Module:Arguments]]).getArgs
local fDataPath = [[Module:Data/Geysers]]
local fData = mw.loadData(fDataPath)
local exception = {}

function p._main(geyserData, geyserCode)
    local out = {}
    out["ID"] = fstr("<code>%s</code>", geyserData.id)
    out["名称"] = po(geyserCode)
    out["图片"] = fstr("%s.png", out["名称"])
    out["图片说明"] = po(geyserCode:sub(1, -6) .. ".DESC")
    if geyserData.width ~= nil then
        out["宽度"] = geyserData.width
    end
    if geyserData.height ~= nil then
        out["高度"] = geyserData.height
    end
    if geyserData.isGenericGeyser ~= nil then
        out["是否为通用间歇泉"] = geyserData.isGenericGeyser
    end
    if geyserData.geyserType ~= nil then
        local mGeyserType = geyserData.geyserType
        if mGeyserType.id ~= nil then
            out["间歇泉类型ID"] = fstr("<code>%s</code>", mGeyserType.id)
        end
        if mGeyserType.maxPressure ~= nil then
            out["最大压力"] = utils.kg2str(mGeyserType.maxPressure)
        end
        if mGeyserType.element ~= nil then
            out["产物"] = fstr("{{物品|%s}}", utils.getEntry(mGeyserType.element))
        end
        if mGeyserType.temperature ~= nil then
            out["产物温度"] = utils.float2str(mGeyserType.temperature + k0) .. " °C"
        end
        if mGeyserType.diseaseCount ~= nil and mGeyserType.diseaseCount > 0 then
            out["病菌类型"] = fstr(
                "[[%s病菌]]",
                po("STRINGS.DUPLICANTS.DISEASES."..mGeyserType.diseaseId:upper()..".NAME")
            )
            out["病菌数量"] = mGeyserType.diseaseCount
        end
        if mGeyserType.shape ~= nil then
            out["形状"] = mGeyserType.shape
        end
        if mGeyserType.minRatePerCycle ~= nil then
            out["活跃期最小平均产率"] = mGeyserType.minRatePerCycle
        end
        if mGeyserType.maxRatePerCycle ~= nil then
            out["活跃期最大平均产率"] = mGeyserType.maxRatePerCycle
        end
        if mGeyserType.minIterationLength ~= nil then
            out["最小喷发周期"] = mGeyserType.minIterationLength
        end
        if mGeyserType.maxIterationLength ~= nil then
            out["最大喷发周期"] = mGeyserType.maxIterationLength
        end
        if mGeyserType.minIterationPercent ~= nil then
            out["喷发期最小占比"] = mGeyserType.minIterationPercent
        end
        if mGeyserType.maxIterationPercent ~= nil then
            out["喷发期最大占比"] = mGeyserType.maxIterationPercent
        end
        if mGeyserType.minYearLength ~= nil then
            out["最小活跃周期"] = mGeyserType.minYearLength
        end
        if mGeyserType.maxYearLength ~= nil then
            out["最大活跃周期"] = mGeyserType.maxYearLength
        end
        if mGeyserType.minYearPercent ~= nil then
            out["活跃期最小占比"] = mGeyserType.minYearPercent
        end
        if mGeyserType.maxYearPercent ~= nil then
            out["活跃期最大占比"] = mGeyserType.maxYearPercent
        end
    end
    if geyserData.outputRate ~= nil then
        local mOutputRate = geyserData.outputRate
        out["喷发期最小产率"] = mOutputRate.rateIterationOn.min
        out["喷发期最大产率"] = mOutputRate.rateIterationOn.max
        out["活跃期最小产率"] = mOutputRate.rateYearOn.min
        out["活跃期最大产率"] = mOutputRate.rateYearOn.max
        out["全周期最小产率"] = mOutputRate.rateYear.min
        out["全周期最大产率"] = mOutputRate.rateYear.max
    end
    if geyserData.outputMass ~= nil then
        local mOutputMass = geyserData.outputMass
        out["喷发期最小产量"] = mOutputMass.massIterationOn.min
        out["喷发期最大产量"] = mOutputMass.massIterationOn.max
        out["活跃期最小产量"] = mOutputMass.massYearOn.min
        out["活跃期最大产量"] = mOutputMass.massYearOn.max
    end
    if geyserData.geotunerEffect ~= nil then
        local geotunerEffect = geyserData.geotunerEffect
        out["调谐消耗"] = fstr(
            "{{物品|%s}} %s", 
            utils.getEntry(geotunerEffect.material),
            utils.kg2str(geotunerEffect.quantity)
        )
        out["调谐持续时间"] = fstr("%s 秒", utils.float2str(geotunerEffect.duration))
        out["产量加成"] = fstr("+%s%%", utils.float2str(geotunerEffect.template.massPerCycleModifier * 100))
        out["产物温度加成"] = fstr("+%s°C", utils.float2str(geotunerEffect.template.temperatureModifier))
    end
    if geyserData.decorProvider ~= nil then
        out["装饰半径"] = geyserData.decorProvider.baseRadius
        out["装饰值"] = geyserData.decorProvider.baseDecor
    end
    if geyserData.primaryElement ~= nil then
        out["元素"] = fstr("{{物品|%s}}", utils.getEntry(geyserData.primaryElement.Name))
        out["质量"] = utils.kg2str(geyserData.primaryElement.Mass)
        out["初始温度"] = utils.float2str(geyserData.primaryElement.InternalTemperature + k0) .. " °C"
    end
    return out
end

-- test by: = p.main(require("Module:debug").frame({},{debug=1, pagename="清水泉"}))
-- test by: = p.main(require("Module:debug").frame({},{debug=1, pagename="污水泉"}))

function p.main(frame)
    local args = getArgs(frame)
    local infos = {}
    local geysers = {}

    if args[1] ~= nil then
        for _, geyserId in ipairs(args) do
            local _, _, geyserCode = utils.getEntry(geyserId)
            if geyserCode == nil then
                error(fstr("找不到间歇泉 '%s',请使用参数1或检查 [[%s]]。", args.pagename, fDataPath))
            end
            table.insert(geysers, {
                id = geyserId,
                code = geyserCode
            })
        end
    else
        local geyserCode = i18ncr:msgRev({
            key = args.pagename,
            args = {
                prefix = "STRINGS.CREATURES.SPECIES.GEYSER."
            }
        } or "")
        if geyserCode == nil then
            error(fstr("找不到间歇泉 '%s',请使用参数1或检查 [[%s]]。", args.pagename, fDataPath))
        end
        local geyserId = geyserCode:gsub("%.NAME$", "")
        geyserId = geyserId:gsub("^STRINGS%.CREATURES%.SPECIES%.GEYSER%.", "")
        table.insert(geysers, {
            id = geyserId,
            code = geyserCode
        })
    end

    for _, geyser in pairs(geysers) do
        geyser.id = exception[geyser.id] ~= nil and exception[geyser.id] or geyser.id
        for k, v in pairs(fData) do
            if k:upper() == ("GeyserGeneric_"..tostring(geyser.id)):upper() then
                local curr = p._main(v, geyser.code)
                table.insert(infos, {
                    label = curr["名称"],
                    data = curr
                })
            end
        end
    end

    if args.debug then
        mw.logObject(infos)
    end
    local infoboxTitle = #infos > 1 and args.pagename or infos[1].label
    return infobox.main(infoboxTitle, infos)
end

return p