2023年政策修订增补工作正在进行中,欢迎参与!
  • Moegirl.ICU:萌娘百科流亡社群 581077156(QQ),欢迎对萌娘百科运营感到失望的编辑者加入
  • Moegirl.ICU:账号认领正在试运行,有意者请参照账号认领流程

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