WIKI公告栏
欢迎各位引航者访问卡拉彼丘WIKI,由于游客访问页面会有一定的页面旧版缓存,建议你登陆B站账号进行浏览,如果您觉得本WIKI有帮助到你,欢迎推荐给身边的引航者。
全站通知:

模块:皮肤

来自卡拉彼丘WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

此模块用于输出角色时装数据和武器皮肤数据,一般用于角色时装筛选页面武器皮肤筛选页面

武器皮肤Data格式:

["武器皮肤名"] = {
WeaponSkinID:武器皮肤ID,对应图片文件名后面的ID数字
WeaponSkinName:武器皮肤名
Weapon:武器名
WeaponSkinQuality:皮肤品质
WeaponSkinGet:获得方式,多个获得方式请用<br />间隔
WeaponSkinJingHe:晶核价格
WeaponSkinJiXian:基弦价格
WeaponSkinLocalizedString:皮肤介绍
WeaponSkinFile:图片文件名
WeaponSkinDesc:备注

local p = {}

-- 引入ACandy模块
local a = require("Module:ACandy")

-- 获取当前页面标题
local function getPageTitle()
    return mw.title.getCurrentTitle().text
end

-- 定义品质颜色
local QualityColor = {
    ["私服"] = "#F78653",
    ["传说"] = "#F85555",
    ["完美"] = "#FFC555",
    ["卓越"] = "#F285FF",
    ["精致"] = "#60A3F7",
    ["初始"] = "#ECECEC"
}

--[[角色时装筛选页--]]
p["角色时装筛选"] = function(frame)
    local data = mw.loadData("Module:皮肤/RoleSkinData") -- 加载角色时装数据
    local html = mw.html.create() -- 创建HTML对象
    local resultList = {} -- 存储结果列表

    -- 遍历每个角色时装
    for roleskin, skins in pairs(data) do
        if skins.File ~= "" then -- 仅处理有文件的皮肤
            -- 处理皮肤获取方式、晶核和基弦
            local SkinGet_data = skins.Get ~= nil and mw.ustring.gsub(skins.Get, "<br />", ",") or skins.Get
            local SkinBabloCrystals_data = skins.BabloCrystals == "" and "无" or skins.BabloCrystals
            local SkinBasestrings_data = skins.Basestrings == "" and "无" or skins.Basestrings
            local SkinBabloCrystals_value = skins.BabloCrystals ~= "" and skins.BabloCrystals .. "[[文件:图标-小巴布洛晶核.png|15px|link=]]" or skins.BabloCrystals
            local SkinBasestrings_value = skins.Basestrings ~= "" and skins.Basestrings .. "[[文件:图标-小基弦.png|15px|link=]]" or skins.Basestrings

            -- 创建HTML行
            local skinssHTML = html
                :tag('tr'):addClass('divsort'):attr('data-param1', skins.Role):attr('data-param2', skins.Quality):attr(
                'data-param3', SkinGet_data):attr('data-param4', SkinBabloCrystals_data):attr('data-param5', SkinBasestrings_data)
                :tag('td'):cssText('padding: 2px;font-size: 15px'):wikitext("[[File:" ..
                skins.File .. "|200px]]<br />'''[[" .. skins.Role .. "]]:" .. skins.Name .. "'''"):done()
                :tag('td'):cssText('padding: 2px'):wikitext(frame:expandTemplate { title = '稀有度标签', args = { skins.Quality } })
                :done()
                :tag('td'):cssText('width: 10%;padding: 2px'):wikitext(skins.Get):done()
                :tag('td'):cssText('width: 8%;padding: 2px'):wikitext(SkinBabloCrystals_value):done()
                :tag('td'):cssText('width: 8%;padding: 2px'):wikitext(SkinBasestrings_value):done()
                :tag('td'):addClass('visible-md visible-sm visible-lg'):cssText('width: 40%;padding: 2px'):wikitext(skins.LocalizedString):done()
                :tag('td'):cssText('width: 15%;padding: 2px'):wikitext(skins.Desc):done()
            table.insert(resultList, tostring(skinssHTML)) -- 将结果添加到列表
        end
    end
    local result = table.concat(resultList) -- 合并结果
    return result -- 返回最终结果
end


--[[角色页角色时装--]]
local function createSkinTab(frame, characterName, skinName, skinQuality)
    local BorderColor = QualityColor[skinQuality] -- 获取品质颜色
    local SkinTabNav, SkinTabContent = "", ""

    if skinQuality ~= "卓越" then
        SkinTabNav = a.li { style = "display: inline;border-radius:5px;margin:0 3px;padding:5px;", frame:callParserFunction('#tag:a', { '立绘', href = '#' .. skinName .. '立绘', ['data-toggle'] = 'tab' }) }
        SkinTabContent = a.div { class = "tab-pane", id = skinName .. "立绘", "[[文件:" .. characterName .. "-" .. skinName .. "立绘.png]]" }
    end

    -- 返回时装标签和内容
    return a.li { class = "bili-list-style", style = "border-radius: 6px;background:rgb(82,87,93);",
            a.span { class = "tab-panel", style = "border-radius: 5px;width:100%;border:4px solid " .. BorderColor .. ";",
                skinName
            }
        },
        a.div { class = "resp-tab-content",
            a.div { class = "tab skintab", style = "display: flex; flex-direction: row-reverse; width: 100%;",
                a.ul { class = "tab-nav", style = "writing-mode: vertical-rl;margin: 0 0 0 0.5em;",
                    a.li { class = "active", style = "display: inline;border-radius:5px;margin:0 3px;padding:5px;",frame:callParserFunction('#tag:a', { '模型正面', href = '#' .. skinName .. '模型正面', ['data-toggle'] = 'tab' }) },
                    a.li { style = "display: inline;border-radius:5px;margin:0 3px;padding:5px;", frame:callParserFunction('#tag:a', { '模型背面', href = '#' .. skinName .. '模型背面', ['data-toggle'] = 'tab' }) },
                    SkinTabNav
                },
                a.div { class = "tab-content",
                    a.div { class = "tab-pane active", id = skinName .. "模型正面", "[[文件:" .. characterName .. "时装-" .. skinName .. ".png|class=radius5|link=]]" },
                    a.div { class = "tab-pane", id = skinName .. "模型背面", "[[文件:" .. characterName .. "时装背面-" .. skinName .. ".png|class=radius5|link=]]" },
                    SkinTabContent
                }
            }
        }
end

p["角色时装"] = function(frame)
    local data = mw.loadData("Module:皮肤/RoleSkinData") -- 加载角色皮肤数据

    local characterName = getPageTitle() -- 获取角色名称
    local skinsByQuality = {
        ["初始"] = {}, ["私服"] = {}, ["传说"] = {}, ["完美"] = {}, ["卓越"] = {},
    }

    -- 根据品质分类角色皮肤
    for skinName, skinData in pairs(data) do
        local skinsOfThisQuality = skinsByQuality[skinData.Quality]
        if skinsOfThisQuality and skinData.Role == characterName then
            skinsOfThisQuality[#skinsOfThisQuality + 1] = skinData.Name
        end
    end

    local tabLabels, tabBodies = {}, {}
    -- 创建每个品质的标签和内容
    for _, quality in ipairs({ "初始", "私服", "传说", "完美", "卓越" }) do
        local len = #tabLabels
        for i, skinName in ipairs(skinsByQuality[quality]) do
            local label, body = createSkinTab(frame, characterName, skinName, quality)
            tabLabels[len + i] = label
            tabBodies[len + i] = body
        end
    end

    if tabLabels[1] then
        tabLabels[1].class = tabLabels[1].class .. " active" -- 设置第一个标签为激活状态
        tabBodies[1].style = "display:block" -- 显示第一个内容
    end

    -- 返回角色时装的HTML
    return a.h2 "角色时装",
        a.div { class = "resp-tabs", style = "border-spacing:0",
            a.ul { class = "resp-tabs-list clearfix", style = "margin-left:0;margin-top:0;border-radius:5px;",
                tabLabels,
            },
            a.div { class = "resp-tabs-container", style = "margin-bottom: 5px;",
                tabBodies,
            },
        }, a.br
end


--[[意识重构角色时装表--]]
p["意识重构时装筛选"] = function(frame)
    local data = mw.loadData("Module:皮肤/RoleSkinData") -- 加载角色皮肤数据
    local skinget = frame.args[1] -- 获取筛选参数
    local html = mw.html.create() -- 创建HTML对象
    local resultList = {} -- 存储结果列表

    -- 遍历所有角色皮肤
    for skin, skinData in pairs(data) do
        if string.find(skinData.Get, skinget, 1, true) then -- 根据获取条件筛选
            -- 创建HTML行
            local roleskinsHTML = html
                :tag('tr')
                :tag('td'):cssText('font-size: 16px'):wikitext("[[File:" ..
                skinData.File .. "|150px|link=]]<br />'''[[" .. skinData.Role .. "]]:" .. skinData.Name .. "'''"):done()
                :tag('td'):wikitext(frame:expandTemplate { title = '稀有度标签', args = { skinData.Quality } }):done()
                :tag('td'):cssText('width: 70%'):wikitext(skinData.LocalizedString):done()
                :done()
        end
    end
    table.insert(resultList, tostring(html:done())) -- 添加到结果列表
    local result = table.concat(resultList) -- 合并结果
    return result -- 返回最终结果
end


--[[武器页武器外观--]]
p["武器外观"] = function(frame)
    local a = require("Module:ACandy") -- 引入ACandy模块
    local data = mw.loadData("Module:皮肤/WeaponSkinData") -- 加载武器皮肤数据

    local WeaponName = getPageTitle() -- 获取武器名称
    local skinsByQuality = {
        ["传说"] = {}, ["完美"] = {}, ["卓越"] = {}, ["精致"] = {},
    }

    -- 根据品质分类武器皮肤
    for skinName, skinData in pairs(data) do
        local skinsOfThisQuality = skinsByQuality[skinData.Quality]
        if skinsOfThisQuality and skinData.Weapon == WeaponName then
            skinsOfThisQuality[#skinsOfThisQuality + 1] = skinData.Name
        end
    end

    local tabLabels, tabBodies = {}, {}
    -- 创建每个品质的标签和内容
    for _, quality in ipairs({ "传说", "完美", "卓越", "精致" }) do
        local len = #tabLabels
        for i, skinName in ipairs(skinsByQuality[quality]) do
            local BorderColor = QualityColor[quality] -- 获取品质颜色
            local WeaponSkinParts = mw.text.split(skinName, "-") -- 分割武器皮肤名称
            local WeaponSkinName = WeaponSkinParts[2]  
            tabLabels[len + i] = a.li { class = "bili-list-style", style = "border-radius: 6px;background:rgb(82,87,93);",
                a.span { class = "tab-panel", style = "border-radius: 5px;width:100%;border:4px solid " .. BorderColor .. ";",
                    WeaponSkinName,
                }
            }
            tabBodies[len + i] = a.div { class = "resp-tab-content",
                "[[File:", skinName, ".png|500px|center|link=|class=radius5]]",
            }
        end
    end
    if tabLabels[1] then
        tabLabels[1].class = tabLabels[1].class .. " active" -- 设置第一个标签为激活状态
        tabBodies[1].style = "display:block" -- 显示第一个内容
    end

    -- 返回武器外观的HTML
    return a.div { class = "resp-tabs", style = "border-spacing:0",
            a.ul { class = "resp-tabs-list clearfix", style = "margin-left:0;margin-top:0",
                tabLabels,
            },
            a.div { class = "resp-tabs-container", style = "margin-bottom: 5px;",
                tabBodies,
            },
        }
end


--[[武器皮肤筛选页--]]
p["武器皮肤筛选"] = function(frame)
    local data = mw.loadData("Module:皮肤/WeaponSkinData") -- 加载武器皮肤数据
    local html = mw.html.create() -- 创建HTML对象
    local resultList = {} -- 存储结果列表

    -- 遍历每个武器皮肤
    for WeaponSkin, skins in pairs(data) do
        -- 处理皮肤获取方式、晶核和基弦
        local SkinGet_data = mw.ustring.gsub(skins.Get, "<br />", ",")
        local SkinBabloCrystals_data = skins.BabloCrystals == "" and "无" or skins.BabloCrystals
        local SkinBasestrings_data = skins.Basestrings == "" and "无" or skins.Basestrings
        local SkinBabloCrystals_value = skins.BabloCrystals ~= "" and skins.BabloCrystals .. "[[文件:图标-小巴布洛晶核.png|15px|link=]]" or skins.BabloCrystals
        local SkinBasestrings_value = skins.Basestrings ~= "" and skins.Basestrings .. "[[文件:图标-小基弦.png|15px|link=]]" or skins.Basestrings
        
        -- 创建HTML行
        local skinssHTML = html
            :tag('tr'):addClass('divsort'):attr('data-param1', skins.Weapon):attr('data-param2', skins.Quality):attr(
                'data-param3', SkinGet_data):attr('data-param4', SkinBabloCrystals_data):attr('data-param5', SkinBasestrings_data)
            :tag('td'):cssText('padding: 2px;font-size: 15px'):wikitext("[[File:" ..
            skins.File .. "|200px]]<br />'''" .. skins.Name .. "'''"):done()
            :tag('td'):cssText('padding: 2px'):wikitext(frame:expandTemplate { title = '稀有度标签', args = { skins.Quality } })
            :done()
            :tag('td'):cssText('width: 10%;padding: 2px'):wikitext(skins.Get):done()
            :tag('td'):cssText('width: 8%;padding: 2px'):wikitext(SkinBabloCrystals_value):done()
            :tag('td'):cssText('width: 8%;padding: 2px'):wikitext(SkinBasestrings_value):done()
            :tag('td'):addClass('visible-md visible-sm visible-lg'):cssText('width: 40%;padding: 2px'):wikitext(skins.LocalizedString):done()
            :tag('td'):cssText('width: 15%;padding: 2px'):wikitext(skins.Desc):done()
        table.insert(resultList, tostring(skinssHTML)) -- 将结果添加到列表
    end
    local result = table.concat(resultList) -- 合并结果
    return result -- 返回最终结果
end


--[[意识重构武器皮肤表--]]
p["意识重构皮肤筛选"] = function(frame)
    local data = mw.loadData("Module:皮肤/WeaponSkinData") -- 加载武器皮肤数据
    local skinget = frame.args[1] -- 获取筛选参数
    local html = mw.html.create() -- 创建HTML对象
    local resultList = {} -- 存储结果列表

    -- 遍历所有武器皮肤
    for skin, skinData in pairs(data) do
        if string.find(skinData.Get, skinget, 1, true) then -- 根据获取条件筛选
            -- 创建HTML行
            local skinssHTML = html
                :tag('tr')
                :tag('td'):cssText('font-size: 16px'):wikitext("[[File:" .. skinData.File ..
                "|200px]]<br />'''" .. skinData.Name .. "'''"):done()
                :tag('td'):wikitext(frame:expandTemplate { title = '稀有度标签', args = { skinData.Quality } }):done()
                :tag('td'):cssText('width: 70%'):wikitext(skinData.LocalizedString):done()
                :done()
        end
    end
    table.insert(resultList, tostring(html:done())) -- 添加到结果列表
    local result = table.concat(resultList) -- 合并结果
    return result -- 返回最终结果
end

return p