Module:信息框/食物
跳转到导航
跳转到搜索
local infobox = require([[Module:信息框]])
local fstr = mw.ustring.format
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 = 'group',
header = '食物保鲜',
children = {
{
tag = 'data',
source = '是否会腐烂',
label = '是否会腐烂'
},
{
tag = 'data',
source = '变质时间',
label = '变质时间'
},
{
tag = 'data',
source = '腐烂时间',
label = '腐烂时间'
},
{
tag = 'data',
source = '冷藏温度',
label = '<abbr title = "将食物储存在低于该温度的条件下可进一步减慢腐烂">冷藏温度</abbr>'
},
{
tag = 'data',
source = '深度冷冻温度',
label = '<abbr title = "温度低于该温度会大大延长食物的保质期">深度冷冻温度</abbr>'
},
}
},
{
tag = 'group',
header = '制作配方',
children = {
{
tag = 'data',
source = '制作建筑',
label = '制作建筑',
},
{
tag = 'data',
source = '制作时间',
label = '制作时间',
},
{
tag = 'data',
source = '配方',
label = '配方',
},
},
},
{
tag = 'group',
header = '构成',
attr = {collapse = 'closed'},
children = {
{
tag = 'data',
source = '元素',
label = '主要元素'
},
{
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, 'food')
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