local p = {}
function p.main(frame)
local args = frame.args
local parentArgs = frame:getParent().args
-- 使用父模板的参数,如果没有则使用当前参数
args = parentArgs and parentArgs or args
-- 样式定义
local style1 = 'background:#000000; color:#FFFFFF; font-size:85%; padding:2px; border:2px; border-style:solid; border-radius:10px;width:225px;'
local style2 = 'background:#FFD700; color:#000000; font-size:85%; padding:2px; border:2px; border-style:solid; border-radius:10px;width:225px;'
-- 构建表格输出
local output = {}
-- 第一个表格:资料分类
table.insert(output, '{| align=center width=450px style="border:0px; text-align:center; line-height:1.3em; border-collapse: separate;" class="infotemplate"')
table.insert(output, '|-')
table.insert(output, '| style="' .. style1 .. '" | \'\'\'资料分类\'\'\' ||style="width:225px;"| \'\'\'' .. (args['special-class'] or '能力者') .. '\'\'\'')
table.insert(output, '|}')
-- 第二个表格:能力信息
table.insert(output, '{| align=center width=450px style="border:0px; text-align:center; line-height:1.3em; border-collapse: separate;" class="infotemplate"')
-- 能力行
table.insert(output, '|-')
local abilityText = '\'\'\'未填入能力\'\'\''
if args['中文名'] then
local abilityName
if args['英文名'] then
-- 使用HTML ruby标签替代wikitext ruby模板
abilityName = '<ruby>' .. args['中文名'] .. '<rt>' .. args['英文名'] .. '</rt></ruby>'
else
abilityName = args['中文名']
end
-- 添加类别前缀
if args['类别'] and args['类别'] ~= '' then
abilityText = '\'\'\'' .. args['类别'] .. '-' .. abilityName .. '\'\'\''
elseif args['type'] and args['type'] ~= '' then
abilityText = '\'\'\'' .. args['type'] .. '能力系-' .. abilityName .. '\'\'\''
else
abilityText = '\'\'\'' .. abilityName .. '\'\'\''
end
end
table.insert(output, '| style="' .. style2 .. '"| \'\'\'能力\'\'\' ||style="width:225px;"| ' .. abilityText)
-- 素养判定行
table.insert(output, '|-')
local levelText = '未知能力者'
local levelRuby = 'Level x'
if args['lv'] then
local levelMap = {
['0'] = {'无能力者', 'Level 0'},
['1'] = {'低能力者', 'Level 1'},
['2'] = {'异能力者', 'Level 2'},
['3'] = {'强能力者', 'Level 3'},
['4'] = {'大能力者', 'Level 4'},
['5'] = {'超能力者', 'Level 5'},
['6'] = {'绝对能力者', 'Level 6'}
}
if levelMap[args['lv']] then
levelText = levelMap[args['lv']][1]
levelRuby = levelMap[args['lv']][2]
end
end
-- 使用HTML ruby标签替代wikitext ruby模板
local levelDisplay = '\'\'\'<ruby>' .. levelText .. '<rt>' .. levelRuby .. '</rt></ruby>\'\'\''
table.insert(output, '| style="' .. style2 .. '"| \'\'\'素养判定\'\'\' ||style="width:225px;"| ' .. levelDisplay)
-- 处理skill参数
local skillIndex = 1
while args['skill' .. skillIndex] do
table.insert(output, '|-')
table.insert(output, '| style="' .. style2 .. '"| \'\'\'具体表现' .. skillIndex .. '\'\'\' ||style="width:225px"| \'\'\'' .. args['skill' .. skillIndex] .. '\'\'\'')
skillIndex = skillIndex + 1
end
-- other参数
if args['other'] then
table.insert(output, '|-')
table.insert(output, '| style="' .. style2 .. '" | \'\'\'其他\'\'\' ||style="width:225px;"| \'\'\'' .. args['other'] .. '\'\'\'')
end
table.insert(output, '|}')
return table.concat(output, '\n')
end
return p