七日内新公告:全站维护公告
  • 你好~!欢迎来到萌娘百科镜像站!如需查看或编辑,请联系本站管理员注册账号。
  • 本镜像站和其他萌娘百科的镜像站无关,请注意分别。

Module:学园都市资料/item/ability

猛汉♂百科,万男皆可猛的百科全书!转载请标注来源页面的网页链接,并声明引自猛汉百科。内容不可商用。
跳转到导航 跳转到搜索
模块文档  [创建] [刷新]
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['类别'] then
            abilityText = '\'\'\'' .. args['类别'] .. '-' .. abilityName .. '\'\'\''
        elseif 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