请登录
玩家共建非官方战双WIKI,做最还原游戏内UI体验的WIKI!    
战双WIKI反馈留言板 · WIKI编辑教程 · BWIKI收藏到桌面的方法说明

全站通知:

模块:LevelIntroUtil

来自战双帕弥什WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

此模块的文档可以在模块:LevelIntroUtil/doc创建

local p = {}

function p.processChars(frame)
    local args = require('模块:Arguments').getArgs(frame)
    local input = args[1] or ''
    local charBlocks = {}
    
    local chars = mw.text.split(input, ',')
    for _, charName in ipairs(chars) do
        local name = mw.text.trim(charName)
        if name ~= '' then
            local imgHtml = ''
            if name == '灰鸦指挥官' then
                imgHtml = string.format(
                    '<div style="display:inline-block; margin:0 4px; text-align:center;">[[File:角色 灰鸦指挥官 普通.png|40px|link=世界观/灰鸦指挥官]]<br>[[世界观/灰鸦指挥官|灰鸦指挥官]]</div>'
                )
            elseif name == '卡俄斯' then
                imgHtml = string.format(
                    '<div style="display:inline-block; margin:0 4px; text-align:center;">[[File:角色 卡俄斯 普通.png|40px|link=世界观/卡俄斯]]<br>[[世界观/卡俄斯|卡俄斯]]</div>'
                )
            else
                local imgName = string.gsub(name, '·', ' ')
                imgHtml = string.format(
                    '<div style="display:inline-block; margin:0 4px; text-align:center;">[[File:角色 %s 普通.png|40px|link=%s]]<br>[[%s]]</div>',
                    imgName, name, name
                )
            end
            table.insert(charBlocks, imgHtml)
        end
    end
    
    return table.concat(charBlocks, '')
end

function p.processAchievementsList(frame)
    local args = require('模块:Arguments').getArgs(frame)
    local types = mw.text.split(args[1] or '', ',')
    local names = mw.text.split(args[2] or '', ',')
    local descs = mw.text.split(args[3] or '', ',')
    local conds = mw.text.split(args[4] or '', ',')

    local typeIconMap = {
        ['普通'] = { file = '成就 普通.png' },
        ['稀有'] = { file = '成就 稀有.png' },
        ['隐藏'] = { file = '成就 隐藏.png' }
    }
    local defaultConfig = typeIconMap['普通']

    local achList = {}
    for i = 1, #types do
        local t = types[i] or ''
        local n = names[i] or ''
        if t ~= '' and n ~= '' then
            local d = descs[i] or ''
            local c = conds[i] or ''

            local currentConfig = typeIconMap[t] or defaultConfig
            local icon = string.format(
                '<span style="vertical-align: middle;">[[File:%s|20px|link=]]</span>',
                currentConfig.file
            )

            local line = string.format('%s <span style="color: #0f70bc; font-weight: bold;">%s</span><br>', icon, n)
            if d ~= '' then line = line .. d .. '<br>' end
            if c ~= '' then line = line .. string.format('<span style="color: #888;">※%s</span><br>', c) end

            table.insert(achList, line)
        end
    end

    return table.concat(achList, '')
end

return p