Module:表格/流星爆炸效果

来自缺氧 Wiki
跳转到导航 跳转到搜索

可在Module:表格/流星爆炸效果/doc创建此模块的帮助文档

-- Module:表格/流星爆炸效果
local p = {}
local fstr = mw.ustring.format -- shortcut for formattig a string
local getArgs = require('Dev:Arguments').getArgs
local tb = require([[Module:表格]])
local po = require([[Module:Po]]).po
local utils = require([[Module:Utils]])
local cData = mw.loadData([[Module:Data/Comets]])
local k0 = utils.K0

local function getCometName(itemData)
    if itemData.Name ~= nil then
        local name = po(itemData.Name)
        if not utils.isDefaultT(itemData.Name, name) then
            return fstr("{{物品|%s}}", name)
        end
    end
    return fstr("<code>%s</code>", itemData.Id)
end

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

    table.insert(out, getCometName(itemData))
    -- 爆炸速度
    table.insert(out, fstr("%s ↔ %s", utils.float2str(comet.explosionSpeedRange.x),
        utils.float2str(comet.explosionSpeedRange.y)))
    -- 爆炸温度
    table.insert(out, fstr("%s ↔ %s", utils.float2str(comet.explosionTemperatureRange.x + k0),
        utils.float2str(comet.explosionTemperatureRange.y + k0)))
    -- 溅射范围
    table.insert(out, utils.float2str(comet.splashRadius))
    -- 爆炸后销毁
    table.insert(out, comet.destroyOnExplode == true and "是" or "否")

    return out
end

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

    local dlc = args.dlc
    for cometId, cometData in pairs(cData) do
        if cometData.comet ~= nil then
            local info = p._main(cometData, cometData.comet)
            table.insert(infos, info)
        end
    end

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

return p