置顶公告:【置顶】关于临时开启评论区所有功能的公告(2022.10.22) | 【置顶】关于本站Widget恢复使用的公告
  • 你好~!欢迎来到萌娘百科镜像站!如需查看或编辑,请联系本站管理员注册账号。
  • 本镜像站和其他萌娘百科的镜像站无关,请注意分别。

Module:无畏契约英雄契约

猛汉♂百科,万男皆可猛的百科全书!转载请标注来源页面的网页链接,并声明引自猛汉百科。内容不可商用。
跳到导航 跳到搜索
local getArgs = require('Module:Arguments').getArgs
local p = {}

function p.main(frame)
	local args = getArgs(frame)
	return p._main(frame, args)
end

function p._main(frame, args)
	if not frame then
		frame = mw.getCurrentFrame()
	end

	local agent = args["agent"]
	local img = ""
	local credits =
		{"2000", "2500", "3000", "3500", "4000", "4500", "5500", "6500", "7500", "8000"}
	local titles = {
		["t"] = "称号",
		["c"] = "卡面",
		["k"] = "王国币",
		["s"] = "-{zh-cn:喷漆;zh-tw:塗鴉;}-",
		["b"] = "-{zh-cn:挂饰;zh-tw:吊飾;}-",
		["0"] = "皮肤"
	}
	local nopicflag = false

	local container = mw.html.create():tag("div"):addClass("val-contracts")

	local function createContract(n, img, info)
		container
			:tag("div"):addClass("val-contract")
				:tag("div"):addClass("val-contract-level")
					:wikitext(n):done()
				:tag("div"):addClass("val-contract-img")
					:wikitext(img):done()
				:tag("div"):addClass("val-contract-title")
					:wikitext(args[n .. "-title"]):done()
				:tag("div"):addClass("val-contract-info")
					:wikitext(info):done()
			:allDone()
	end

	for i = 1, 10 do
		local t = args[i .. "-type"] or "0"
		local ext = args[i .. "-format"] or "png"
		local nopic = args[i .. "-nopic"] or "0"

        local imgContent = {
            ["t"] = "[[File:VALORANT_Contract_Title.png|link=]]",
            ["c"] = "[[File:VALORANT_Contract_" .. agent .. "_" .. i .. ".png|x180px|link=]]",
            ["k"] = "[[File:VALORANT_Contract_Kingdom_Credit.png|60px|link=]]"
        }

		if nopic == "1" then
			img = "暂无图片"
			nopicflag = true
		else
			img = imgContent[t] or ("[[File:VALORANT_Contract_" .. agent .. "_" .. i .. "." .. ext .. "|link=]]")
		end

		if t == "k" then
			createContract(i, img, "王国币")
		else
			createContract(i, img, titles[t] .. "<br/>" .. credits[i] .. "王国币")
		end
	end

	if nopicflag then
		container:wikitext("[[Category:无畏契约英雄契约图片存在缺失的条目]]")
	end

	return container
end

return p