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

Module:CbjqLink

猛汉♂百科,万男皆可猛的百科全书!转载请标注来源页面的网页链接,并声明引自猛汉百科。内容不可商用。
跳到导航 跳到搜索
Template-info.svg 模块文档  [创建] [刷新]
local p = {}

-- 名称消歧义映射表
local nameMap = {
    ["里芙"] = "里芙·贝斯特拉",
    ["芙提雅"] = "芙提雅·伊格妮丝",
    ["茉莉安"] = "茉莉安·安德烈奥蒂",
    ["琴诺"] = "琴诺·凯郭尔",
    ["芬妮"] = "芬妮·戈尔登",
    ["恩雅"] = "恩雅·墨尔菲",
    ["凯茜娅"] = "凯茜娅·克莱因",
    ["伊切尔"] = "伊切尔·古斯塔夫",
    ["苔丝"] = "苔丝·科特金",
    ["薇蒂雅"] = "薇蒂雅·香农",
    ["奈莉德"] = "奈莉德·莫罗佐娃",
    ["克罗瑞娜"] = "克罗瑞娜·吉诺拉",
    ["辰星"] = "姬辰星",
    ["晴"] = "鸣濑晴",
    ["妮塔"] = "妮塔(尘白禁区)"
}

-- 颜色映射
local rarityColor = {
    ["4"] = "#c068d6",
    ["5"] = "#f48626"
}

-- 主函数
function p.render(frame)
    local args = frame:getParent().args
    local name = args["名字"] or ""
    local icon = args["icon"] or ""
    local namedisam = nameMap[name] or name

    local html = mw.html.create("div")
        :css("display", "flex")
        :css("flex-direction", "column")
        :css("align-items", "center")
        :css("padding", "0px 10px")

    -- 图标部分
    if icon ~= "" then
        local img1 = args["图片1"] or ""
        local value1 = args["value1"] or ""
        html:wikitext(string.format(
            "[[File:%s|50px|link=%s#%s]]<div>[[%s|%s]]</div>",
            img1, namedisam, mw.uri.anchorEncode(value1), namedisam, name
        ))
    else
        html:wikitext(string.format("[[%s|%s]]", namedisam, name))
    end

    -- 换装部分
    local skinsDiv = mw.html.create("div")
        :css("display", "flex")
        :css("flex-flow", "row wrap")
        :css("justify-content", "center")

    for i = 1, 50 do
        local skin = args["换装" .. i]
        if not skin or skin == "" then break end
        local img = args["图片" .. i] or ("尘白禁区-icon-" .. name .. "-" .. skin .. ".png")
        local rarity = tostring(args["稀有度" .. i] or "0")
        local color = rarityColor[rarity] or "red"
        local displayName = skin
        if not rarityColor[rarity] then
            displayName = "【" .. skin .. "】参数异常"
        end

        local skinDiv = mw.html.create("div")
            :css("display", "flex")
            :css("flex-direction", "column")
            :css("align-items", "center")
            :css("padding", "0 5px")
            :css("width", "max-content")

        skinDiv:wikitext(string.format(
            "[[File:%s|50px|link=%s#%s]]<div>[[%s#%s|<span style=\"color:%s\">%s</span>]]</div>",
            img, namedisam, mw.uri.anchorEncode(skin),
            namedisam, mw.uri.anchorEncode(skin), color, displayName
        ))

        skinsDiv:node(skinDiv)
    end

    html:node(skinsDiv)
    return tostring(html)
end

return p