此处为全站公告,通常对读者进行申明或对该WIKI某些规则进行公告,请在确认后修改本通告。本WIKI编辑权限开放,欢迎收藏起来防止迷路,也希望有爱的小伙伴和我们一起编辑哟~

全站通知:

模块:OutfitDesc

来自星塔旅人WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

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

local p = {}

local nameToId = {
    ["朝霭"] = "1001",
    ["和煦"] = "1002",
    ["晚霞"] = "1003",
    ["粉梦"] = "1004",
    ["孤烟"] = "1005",
    ["甘露"] = "1006",
    ["希冀"] = "1007",
    ["归途"] = "1008",
    ["盛宴"] = "2001",
    ["喧哗"] = "2002",
    ["极乐"] = "2003",
    ["情热"] = "2005",
    ["吉光"] = "2006",
    ["乘风"] = "2007",
    ["泡沫"] = "2008",
    ["黯灭"] = "2009",
    ["坚韧"] = "2010",
    ["???"] = "3001",
    ["???"] = "3002",
    ["热夜的结束"] = "3003",
    ["双月怪盗"] = "3004",
    ["★~嘭嘭少女~★"] = "3005",
    ["晚安"] = "3006",
    ["翡翠隙境"] = "3007",
    ["小憩片刻"] = "3008",
    ["“雨中”曲"] = "3009",
    ["水蒸汽症候群"] = "3010",
    ["喵律动"] = "3011",
    ["问候星空"] = "3012",
    ["秋日絮语"] = "3013",
    ["骑士的铁匠"] = "3014",
    ["未闻芳名"] = "3015",
    ["樊笼蔷薇"] = "3016",
    ["★~转转人生~★"] = "3017",
    ["饮料采购日"] = "3018",
    ["妄语"] = "3019",
    ["闪灵"] = "3020",
    ["灵验颂歌"] = "3021",
    ["诅咒爱河"] = "3022",
    ["纯白"] = "3023",
    ["假日泡影"] = "3024",
    ["甜蜜邀约"] = "3025",
    ["清扫时间DA♥YO"] = "3026",
    ["???"] = "3027",
    ["???"] = "3028",
    ["???"] = "3029",
    ["???"] = "3030",
    ["???"] = "3031",
    ["???"] = "3032",
    ["猫神降歌"] = "4001",
    ["空与花与诗"] = "4002",
    ["???"] = "4003",
    ["???"] = "4004",
    ["晴之花"] = "4005",
    ["魔女的秋千"] = "4006",
    ["午夜,堕天使"] = "4007",
    ["???"] = "4008",
    ["“空白”的序章"] = "4009",
    ["沐光祷告"] = "4010",
    ["夏日午后的雨"] = "4011",
    ["狼贪虎视"] = "4012",
    ["远航蓝图"] = "4013",
    ["甜言蜜果"] = "4014",
    ["???"] = "4015",
    ["???"] = "4016",
    ["???"] = "4017",
    ["冰柠与红茶"] = "4018",
    ["一发破的"] = "4019",
    ["闪光之时"] = "4020",
    ["因缘而聚"] = "4021",
    ["午夜喵铃"] = "4022",
    ["涂鸦彩虹"] = "4023",
    ["???"] = "4024",
    ["???"] = "4025",
    ["潋滟故池水"] = "4026",
    ["龙飞凤舞"] = "4027",
    ["白日花园"] = "4028",
    ["???"] = "4029",
    ["午后间隙"] = "4030",
    ["刀与斧的铮鸣"] = "4031",
    ["真相☆梦工厂"] = "4032",
    ["与骨共舞"] = "4033",
    ["???"] = "4034",
    ["???"] = "4035",
    ["迷途的朝圣者"] = "4036",
    ["抓住传说"] = "4037",
    ["波光漫游"] = "4038",
    ["夏日栖息地"] = "4039"
}

local noteEffectMap = {
    ["强攻之音"] = "每级提升0.3%攻击力",
    ["幸运之音"] = "每级提升0.1%暴击率",
    ["暴发之音"] = "每级提升0.46%暴击伤害",
    ["体力之音"] = "每级提升0.3%生命上限",
    ["专注之音"] = "每级提升1.2%普攻伤害",
    ["技巧之音"] = "每级提升0.46%技能伤害",
    ["绝招之音"] = "每级提升1%绝招伤害",
    ["水之音"] = "每级提升0.3%水系伤害",
    ["火之音"] = "每级提升0.3%火系伤害",
    ["风之音"] = "每级提升0.3%风系伤害",
    ["地之音"] = "每级提升0.3%地系伤害",
    ["光之音"] = "每级提升0.3%光系伤害",
    ["暗之音"] = "每级提升0.3%暗系伤害"
}

 local skillIconMap = {
    DiscSkill_1 = "攻击",
    DiscSkill_2 = "暴击",
    DiscSkill_3 = "暴伤",
    DiscSkill_4 = "辅助",
    DiscSkill_5 = "生命",
    DiscSkill_6 = "防御",
    DiscSkill_7 = "充能",
    DiscSkill_8 = "破防",
    DiscSkill_9 = "风",
    DiscSkill_10 = "暗",
    DiscSkill_11 = "地",
    DiscSkill_12 = "水",
    DiscSkill_13 = "火",
    DiscSkill_14 = "光",
}

local function processSkill(skillData, hasNotes)
    local desc = skillData.desc
    local params = {}
    
    desc = desc:gsub(string.char(11), "<br>")
    
    local maxLevels = 0
    for key, value in pairs(skillData) do
        if key:match("^Param%d+$") then
            params[key] = value
            if type(value) == "table" then
                maxLevels = math.max(maxLevels, #value)
            end
        end
    end
    
    if maxLevels == 0 then
        maxLevels = 1
    end
    
    local result = ""
    
    for level = 1, maxLevels do
        local processedDesc = desc
        
        for i = 1, 10 do
            local paramKey = "Param" .. i
            if params[paramKey] then
                local paramValue
                if type(params[paramKey]) == "table" then
                    paramValue = params[paramKey][level] or params[paramKey][#params[paramKey]]
                else
                    paramValue = tostring(params[paramKey])
                end
                paramValue = paramValue:gsub("%%", "%%%%")
                processedDesc = processedDesc:gsub("{" .. i .. "}", paramValue)
            end
        end
        
        processedDesc = processedDesc:gsub("<color=(#?[%w]+)>(.-)</color>", '<span style="color:%1;">%2</span>')
        
        local style = ""
        if level > 1 then
            style = ' style="display:none;"'
        end
        
        result = result .. '<div class="sora_outfit_mainSkill_content_txt" data-level-txt="' .. level .. '"' .. style .. '>' .. processedDesc .. '</div>'
    end
    
    if hasNotes and skillData.Note and skillData.NeedNote then
        for level = 1, maxLevels do
            local noteBoxStyle = ""
            if level > 1 then
                noteBoxStyle = ' style="display:none;"'
            end
            
            result = result .. '<div class="sora_outfit_mainSkill_note_box" data-level-txt="' .. level .. '"' .. noteBoxStyle .. '><span>激活条件:</span>'
            
            for i, note in ipairs(skillData.Note) do
                local needNote = skillData.NeedNote[level] or skillData.NeedNote[#skillData.NeedNote]
                local noteForImg = note:gsub("之音", "")
                
                result = result .. '<div class="sora_outfit_mainSkill_note_content">[[文件:秘纹_音符_' .. noteForImg .. '.png|link=|55px]]'
                result = result .. '<div class="sora_outfit_mainSkill_note_content_txt"><span>' .. note .. '</span><span>≥Lv.' .. needNote .. '</span></div>'
                result = result .. '</div>'
            end
            
            result = result .. '</div>'
        end
    end
    
    return result
end

function p.main(frame)
    local args = frame.args
    local outfit = args[1]
    local skillType = args[2]

    local IdTitle = mw.title.new('Mediawiki:Outfit.json')
    local itemcontent = IdTitle and IdTitle:getContent() or nil
    local IdData = mw.text.jsonDecode(itemcontent)
    local id = tostring(IdData[outfit])
    if not id then
        return "秘纹不存在"
    end

    local title = mw.title.new('Mediawiki:Outfit/' .. id .. '.json')
    local content = title and title:getContent() or nil
    if not content then
        return "JSON文件未找到"
    end
    
    local data = mw.text.jsonDecode(content)
    
    if skillType == "主旋律技能" then
        local mainSkill = data.skill and data.skill.MainSkill
        if not mainSkill then
            return "主旋律技能数据未找到"
        end
        return processSkill(mainSkill, false)
    end

    if skillType == "主技能名称" then
        local mainSkill = data.skill and data.skill.MainSkill
        if not mainSkill then
            return "主旋律技能数据未找到"
        end
        return mainSkill.name or ""
    end    
    
    
    if skillType == "协奏技能1" then
        local secondarySkill1 = data.skill and data.skill.SecondarySkill1
        if not secondarySkill1 then
            return "协奏技能1数据未找到"
        end
        return processSkill(secondarySkill1, true)
    end

    if skillType == "协奏技能1名称" then
        local secondarySkill1 = data.skill and data.skill.SecondarySkill1
        if not secondarySkill1 then
            return "协奏技能1数据未找到"
        end
        return secondarySkill1.name or ""
    end
    
    if skillType == "协奏技能2" then
        local secondarySkill2 = data.skill and data.skill.SecondarySkill2
        if not secondarySkill2 then
            return "协奏技能2数据未找到"
        end
        return processSkill(secondarySkill2, true)
    end

    if skillType == "协奏技能2名称" then
        local secondarySkill2 = data.skill and data.skill.SecondarySkill2
        if not secondarySkill2 then
            return "协奏技能2数据未找到"
        end
        return secondarySkill2.name or ""
    end
    
        if skillType == "辅位效果" then
        local subNoteSkills = data.skill and data.skill.SubNoteSkills
        if not subNoteSkills then
            return "辅位效果数据未找到"
        end
        
        local result = ""
        local noteCount = 0
        
        for key, value in pairs(subNoteSkills) do
            if key:match("^Note%d+$") then
                noteCount = noteCount + 1
            end
        end
        
        for noteIndex = 1, noteCount do
            local noteKey = "Note" .. noteIndex
            local needNoteKey = "NeedNote" .. noteIndex
            local note = subNoteSkills[noteKey]
            local needNoteArray = subNoteSkills[needNoteKey]
            
            if note and needNoteArray then
                local noteForImg = note:gsub("之音", "")
                local effectDesc = noteEffectMap[note] or "未知效果"
                
                for level = 1, 9 do
                    local style = ""
                    if level > 1 then
                        style = ' style="display:none;"'
                    end
                    
                    local needNoteValue = needNoteArray[level] or needNoteArray[#needNoteArray]
                    
                    result = result .. '<div class="sora_outfit_otherskill_note_box" data-level-txt="' .. level .. '"' .. style .. '>[[文件:秘纹_音符_' .. noteForImg .. '.png|link=]]'
                    result = result .. '<div class="sora_outfit_otherskill_note_txt_box"><span>' .. note .. '</span><span>' .. effectDesc .. '</span><span>Lv.' .. needNoteValue .. '</span></div>'
                    result = result .. '</div>'
                end
            end
        end
        
        return result
    end
    
        if skillType == "属性数值" then
        local attributes = data.attributes
        if not attributes then
            return "属性数值数据未找到"
        end
        
        local result = {}
        for key, value in pairs(attributes) do
            if key ~= "lvl" then
                result[key] = value
            end
        end
        
        return mw.text.jsonEncode(result)
    end

    if skillType == "主技能图标" then
        local mainSkill = data.skill and data.skill.MainSkill
        if not mainSkill then
            return "主旋律技能数据未找到"
        end
        local icon = mainSkill.icon
        if icon then
            local iconName = skillIconMap[icon]
            if iconName then
                return "通用_" .. iconName
            else
                return data.name or ""
            end
        end
        return data.name or ""
    end
    
    if skillType == "协奏技能1图标" then
        local secondarySkill1 = data.skill and data.skill.SecondarySkill1
        if not secondarySkill1 then
            return "协奏技能1数据未找到"
        end
        local icon = secondarySkill1.icon
        if icon then
            local iconName = skillIconMap[icon]
            if iconName then
                return "通用_" .. iconName
            else
                return data.name or ""
            end
        end
        return data.name or ""
    end
    
    if skillType == "协奏技能2图标" then
        local secondarySkill2 = data.skill and data.skill.SecondarySkill2
        if not secondarySkill2 then
            return "协奏技能2数据未找到"
        end
        local icon = secondarySkill2.icon
        if icon then
            local iconName = skillIconMap[icon]
            if iconName then
                return "通用_" .. iconName
            else
                return data.name or ""
            end
        end
        return data.name or ""
    end    
    
    return "技能类型不支持"
end

return p