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 function createAlt(d)
return frame:expandTemplate{title = "svg", args = {
width = 70, height = 70, viewBox = '0 0 24 24', style = 'color:#A0A2A4;margin-left:-35px;padding-right:35px;',
frame:expandTemplate{title = "svg/path", args = {d, fill = 'currentColor'}}
}}
end
-- Originate from BoxIcons Solid
local alts = {
["c"] = createAlt('M17.988 22a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2zM9 5h6v2H9zm5.25 6.25A2.26 2.26 0 0 1 12 13.501c-1.235 0-2.25-1.015-2.25-2.251S10.765 9 12 9a2.26 2.26 0 0 1 2.25 2.25M7.5 18.188c0-1.664 2.028-3.375 4.5-3.375s4.5 1.711 4.5 3.375v.563h-9z'),
["s"] = createAlt('M13.003 3h2v2h-2zM16 3h2v2h-2zm0 3h2v2h-2zm3-3h2v2h-2zm0 3h2v2h-2zm0 3h2v2h-2zM4.012 12v9a1 1 0 0 0 1 1H13a1 1 0 0 0 1-1v-9a4 4 0 0 0-4-4H8.012a4 4 0 0 0-4 4M7.003 2h4v4h-4z'),
["b"] = createAlt('M11.445 21.832a1 1 0 0 0 1.11 0l9-6A1 1 0 0 0 21.8 14.4l-9-12c-.377-.504-1.223-.504-1.6 0l-9 12a1 1 0 0 0 .245 1.432zm8.12-7.078L12 19.798V4.667z'),
["0"] = createAlt('M5 12H4v8a2 2 0 0 0 2 2h5V12zm13 0h-5v10h5a2 2 0 0 0 2-2v-8zm.791-5A5 5 0 0 0 19 5.5C19 3.57 17.43 2 15.5 2c-1.622 0-2.705 1.482-3.404 3.085C11.407 3.57 10.269 2 8.5 2C6.57 2 5 3.57 5 5.5c0 .596.079 1.089.209 1.5H2v4h9V9h2v2h9V7zM7 5.5C7 4.673 7.673 4 8.5 4c.888 0 1.714 1.525 2.198 3H8c-.374 0-1 0-1-1.5M15.5 4c.827 0 1.5.673 1.5 1.5C17 7 16.374 7 16 7h-2.477c.51-1.576 1.251-3 1.977-3')
}
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 = alts[t]
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(frame:expandTemplate{title = "ac", args = "无畏契约英雄契约图片存在缺失的条目"})
end
return container
end
return p