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

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

全站通知:

模块:信息框/疾病

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

用于模块:Module:疾病信息框



local infobox = require([[Module:信息框]])
local p = {}

local innerNodes = {
    {
        tag = 'image',
        source = '图片',
        children = {
            {
                tag = 'caption',
                source = '图片说明'
            }
        }
    },
    {
        tag = 'data',
        source = 'ID',
        label = 'ID'
    },
    {
        tag = 'data',
        source = '疾病类型',
        label = '疾病类型'
    },
    {
        tag = 'data',
        source = '持续时间',
        label = '持续时间'
    },
    {
        tag = 'data',
        source = '严重性',
        label = '严重性'
    },
    {
        tag = 'data',
        source = '致病病菌',
        label = '致病病菌'
    },
    {
        tag = 'data',
        source = '感染媒介',
        label = '感染媒介'
    },
    {
        tag = 'group',
        header = '效果',
        attr = {collapse = 'open'},
        children = {
            {
                tag = 'data',
                source = '病症',
                label = '病症'
            },
            {
                tag = 'data',
                source = '恢复效果',
                label = '恢复效果'
            }
        }
    }
}

-- test: = p.infoboxContent{['活跃周期时长'] = 3200, ['喷发期产率'] = 5}
function p.infoboxContent(args)
    local generated = {}
    for _, n in ipairs(innerNodes) do
        local child = infobox.genNode(n, args)
        if child ~= nil then
            table.insert(generated, child)
        end
    end
    return generated
end

function p.main(title, data, raw)
    local contentNodes = nil
    if #data == 1 then
        contentNodes = p.infoboxContent(data[1].data)
    else
        local panelData = {}
        for _, pData in ipairs(data) do
            table.insert(panelData, {
                label = pData.label,
                content = p.infoboxContent(pData.data)
            })
        end
        contentNodes = {
            infobox.panel(panelData)
        }
    end
    return infobox.infobox(title, contentNodes, raw, 'sickness')
end

function p.demo(frame)
    local getArgs = require('Dev:Arguments').getArgs
    local args = getArgs(frame)
    return p.main(args['标题'], {
        {
            data = args
        }
    }, args.raw)
end

return p