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

全站通知:

模块:DragonSoul

来自龙族:卡塞尔之门WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

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

local p = {}

local Highlight = require('Module:Highlight') -- usage: highlightContent
local Data = mw.text.jsonDecode(mw.title.new('Data:龙文.json'):getContent() or '{}')
local starData = mw.text.jsonDecode(mw.title.new('Data:龙文/星级效果.json'):getContent() or '{}')

function p.main(frame)
    -- 获取传入的第一个参数(龙文的名字)
    local param = frame.args[1]
    local output = {}

    -- 使用传入的参数作为龙文的名字
    local dragonsoul = Data[param]  -- 使用传入的参数
    local name = param  -- 龙文的名字
    local type = dragonsoul.type
    local skill = dragonsoul.skill
    local effect = dragonsoul.effect
    local rare = dragonsoul.rare
    local en_type = (type == "攻击型" and "attack") or (type == "防御型" and "defense") or (type == "辅助型" and "support")
    local deco = (type == "攻击型" and "1") or (type == "防御型" and "2") or (type == "辅助型" and "3")
    local orderedOptions = {
    "康斯坦丁的追忆", 
    "奥丁之怒吼", 
    "利维坦之歌", 
    "耶梦加得的低语", 
    "白帝御诏", 
    "大蛇信语", 
    "天照命的神言"
}
    
    
    table.insert(output,'<div style="display:flex;position:fixed;z-index:4;top:150px;left:12px">')
        for _, suffix in ipairs({1, 2, 3, 4, "光", "暗"}) do
            local enSuffix = (suffix == "光" and "Light") or (suffix == "暗" and "Dark") or tostring(suffix)

         -- 添加龙纹选择框
            table.insert(output, string.format('<div class="dragonsoul-select-container" id="select-dragonsoul-container-%s" style="">', enSuffix))
                        		table.insert(output, string.format('<div class="dragonsoul-select-title">部位-%s</div>', suffix))
            -- 遍历按照顺序排列的选项
for _, option in ipairs(orderedOptions) do
    local optionData = Data[option]  -- 获取对应的选项数据
    if optionData then
        table.insert(output, '<div class="dragonsoul-select-item">')
        table.insert(output, string.format('<div class="select-dragonsoul-img">[[file:龙文_%s.png|link=]]%s</div>', option, option))
        
        -- 获取该选项对应的 effect 数据
        local optionEffect = optionData.effect[suffix]
        local outputOptionEffect = highlightContent(optionEffect)
        
        -- 输出效果内容
        table.insert(output, string.format('<div style="font-size:x-small;color:#ffffffde">%s</div>', outputOptionEffect))
        table.insert(output, '</div>') -- 关闭 select-item
    end
end

            table.insert(output, '</div>')
        end
        table.insert(output, '</div>')

    -- 填充标题部分
    table.insert(output, '<div class="dragonsoul-title">')
   
            
    table.insert(output, '<div style="font-size: large;margin-left:8px">龙文 <sub style="font-family: Merriweather;color: #a7a7a7;font-size: small;font-style: italic;"> / DragonSoul</sub></div>')
    table.insert(output, string.format('<div class="dragonsoul-title-background-%s" style="display:flex;justify-content: space-between;"><div style="position:relative;z-index:1;">%s&nbsp;&nbsp;&nbsp;&nbsp;[[file:icon_%s1.png|24px]]  <span style="font-size:small">推荐:%s</span></div>', en_type, name, en_type, type))
    table.insert(output, '<div style="float:right;display:flex;margin-right:72px;">')
    for _, switchName in ipairs(orderedOptions) do
    	table.insert(output,string.format('<div>[[file:龙文_%s.png|30px|link=%s]]</div>',switchName,switchName))
    end
	table.insert(output, '</div>')
    table.insert(output, string.format('<div class="dragonsoul-title-deco">[[file:icon_dragonsoul_decoration%d.png|200px|link=]]</div>', deco))
    table.insert(output, '</div></div>')
    
    table.insert(output,'<br/><div style="font-style:italic;font-size:small;color:#a7a7a7">点击龙文图标或信息框可以查询该部位其他龙文的部件技能。如有错漏或补充请在评论告知(*/ω\*)</div>')

    table.insert(output, '<div class="dragonsoul-circle-bg">')
    
    table.insert(output, string.format('<div class="dragonsoul-rare">[[file:icon_%s.png|72px]]</div>', rare))

    -- 填充套装属性
    table.insert(output, '<div class="dragonsoul-setEffect-container">')
    table.insert(output, '<div class="dragonsoul-setEffect-title">套装属性</div>')
    table.insert(output, '<div class="dragonsoul-setEffect-text">')

    -- 预定义技能效果描述
    local skillDescriptions = {
        "2件套",
        "4件套",
        "集齐24星时"
    }

    -- 遍历 skill 数组并显示每个技能效果
    for i, skillDesc in ipairs(skill) do
        local description = skillDescriptions[i] or "未知技能效果"
        table.insert(output, string.format('<span class="dragonsoul-setEffect-badge">%s</span>%s<br/>', description, highlightContent(skillDesc)))
    end

    table.insert(output, '</div></div>')

    -- 填充圆圈容器
    table.insert(output, '<div class="dragonsoul-circle-container">')

    -- 将隐藏字段替换为 div,并使用 data-* 属性来存储数据
--table.insert(output, '<div id="selected-dragonsoul-id" data-selected-id="" style="display:none;"></div>')


    for _, suffix in ipairs({1, 2, 3, 4, "光", "暗"}) do
        -- 获取数据
        local getStarData = starData[type][suffix]

        if getStarData then
            -- 处理光暗部分,英文后缀
            local enSuffix = (suffix == "光" and "Light") or (suffix == "暗" and "Dark") or tostring(suffix)
            local imageSuffix = (suffix == "光" and "Light") or (suffix == "暗" and "Dark") or tostring(suffix)
            local imageName = (imageSuffix == "") and name or (name.."_" .. suffix)
            local bgClass = (suffix == "光" or suffix == "暗") and "bg" .. imageSuffix or string.format("bg%s", enSuffix)

            -- 设置图片名称和后缀
            local i1to4  = (suffix == "光" and "Light") or (suffix == "暗" and "Dark") or ''
            local image1to4 = (suffix == "光" and name.."_".."光") or (suffix == "暗" and name.."_".."暗") or name
            
            

            
            
            -- 添加背景和图片
            table.insert(output, string.format('<div class="dragonsoul-circle-item dragonsoul-bg dragonsoul-%s">[[file:龙文_背景_ssr.png|72px|link=]]</div>', bgClass))
            table.insert(output, string.format('<div class="dragonsoul-circle-item dragonsoul-%s" id="select-button-%s">[[file:龙文_%s.png|56px|link=]]', enSuffix, enSuffix, image1to4))
            

            -- 文本框
            table.insert(output, '<div class="dragonsoul-text-box dragonsoul-text-box-' .. enSuffix .. '">')
            table.insert(output, string.format('<div class="dragonsoul-text-box-icon dragonsoul-text-box-name">%s-%s</div>', name, suffix))

            -- 部件技能从 effect 字段获取
            local partSkill = effect[(suffix)]
            table.insert(output, string.format('<div style="color:#c3b0b0">部件技能(Lv.100,8阶时)</div>%s', highlightContent(partSkill) or "无部件技能"))

            table.insert(output, '<div style="color:#c3b0b0">星级属性</div>')

            table.insert(output, '<div class="dragonsoul-text-box-starEffect-container">')

            -- 填充星级属性
            for i = 1, 6, 2 do  -- 每次增加 2,意味着每两项属性放在一行
                -- 获取当前的两项属性
                local attribute1 = getStarData[i].attribute
                local value1 = getStarData[i].value
                local attribute2 = getStarData[i+1] and getStarData[i+1].attribute or ""
                local value2 = getStarData[i+1] and getStarData[i+1].value or ""

                -- 开始一行
                table.insert(output, string.format('<div class="dragonsoul-text-box-starEffect-eachRow">'))

                -- 第一项属性
                table.insert(output, string.format('<div class="dragonsoul-text-box-starEffect-item"><div class="dragonsoul-star">[[file:icon_star.png|8px]]%s</div><div>%s</div></div>', attribute1, value1))
                
                -- 第二项属性 (如果存在)
                if attribute2 ~= "" then
                    table.insert(output, string.format('<div class="dragonsoul-text-box-starEffect-item"><div class="dragonsoul-star">[[file:icon_star.png|8px]]%s</div><div>%s</div></div>', attribute2, value2))
                end
                
                -- 结束当前行
                table.insert(output, '</div>') -- 单行结束
            end

            -- 结束星级容器
            table.insert(output, '</div>') -- 星级总flex

            table.insert(output, '</div>') -- 龙文信息结束
            table.insert(output, '</div>')
        else
            -- 如果没有对应数据,可以跳过,或者显示错误信息
            table.insert(output, string.format('<div class="dragonsoul-circle-item dragonsoul-%s">没有数据</div>', suffix))
        end
    end

    -- 结束圆圈容器,在循环外关闭
    table.insert(output, '</div>')

    table.insert(output, '</div>') -- circlebg

    -- 返回输出
    return table.concat(output)
end

return p