-- 用于模板:尘白禁区天启者链接,替代 #var / #vardefine / #forargs
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