Module:Cost/new

From Inkipedia, the Splatoon wiki

Documentation for this module may be created at Module:Cost/new/doc

local p = {}

local specificLink	=	{
	["Bronze scale"]			=	"Fish scale",
	["CQ Points"]				=	"CQ-80#CQ Points",
	["Gold scale"]				=	"Fish scale",
	["Gold Sheldon License"]	=	"Sheldon License",
	["Power Egg (no fish)"]		=	"Power Egg",
	["Silver scale"]			=	"Fish scale",
}

local specificFileName	=	{
	["S"]	=	{},
	["S2"]	=	{
		["Ability chunk"]	=	"S2 Icon Ability Chunk Generic.png",
		["Sardinium"]		=	"S2 Icon Sardinium Shadow.png",	--Not official, this one is shadowed by User:GuyPerfect for wiki purposes
	},
	["S3"]	=	{
		["Ability chunk"]		=	"S3 Icon Ability Chunk Generic.png",
		["Bronze scale"]		=	"S3 Icon bronze fish scale.png",
		["Gold scale"]			=	"S3 Icon gold fish scale.png",
		["Membux"]				=	"SO Icon Membux.png",
		["Power Egg"]			=	"SplatNet 3 icon Power Egg.png",	--Salmon Run Next Wave one, apparently
		["Power Egg (no fish)"]	=	"S3 Icon Power Egg Alterna.png",	--Return of the Mammalians, apparently
		["Prlz"]				=	"SO Icon Prlz.png",
		["Sardinium"]			=	"S2 Icon Sardinium Shadow.png",	--According to User:Skua, S3's looks exactly the same as S2's
		["Silver scale"]		=	"S3 Icon silver fish scale.png",
	},
}

function p.requireFromModule(frame)
	return p.getCostIcon(
		string.upper(frame.game),
		frame.currency,
		frame.price,
		frame.size or 24,
		frame.pricelink
	)
end

function p.invokeFromTemplate(frame)
	return p.getCostIcon(
		string.upper(frame:getParent().args.game),
		frame:getParent().args.currency,
		frame:getParent().args.price,
		frame:getParent().args.size or 24,
		frame:getParent().args.pricelink
	)
end

function p.invokeFromPage(frame)
	return p.getCostIcon(
		string.upper(frame.args.game),
		frame.args.currency,
		frame.args.price,
		frame.args.size or 24,
		frame.args.pricelink
	)
end

function p.getCostIcon(game, currency, price, size, pricelink)
	local fileName		=	specificFileName[game][currency] or string.format("%s Icon %s.png", game, currency)
	local currencyLink	=	specificLink[currency] or currency
	local result		=	string.format("[[File:%s|%dpx|link=%s]]", fileName, size, currencyLink)
	
	if price then
		if pricelink then
			result	=	string.format("%s [[%s|%d]]", result, currencyLink, price)
		else
			result	=	string.format("%s %d", result, price)
		end
	end
	
	return result
end

return p