Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:CosmeticInfo/Paragraph

From MCC Island Wiki
Revision as of 12:26, 30 August 2025 by MTOnline (talk | contribs) (module to automate (nearly the whole of) cosmetics' pages)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:CosmeticInfo/Paragraph/doc

local getArgs = require('Module:Arguments').getArgs
local info = require('Module:CosmeticInfo')
local crates = require('Module:CosmeticCrates')
local machine = require('Module:CosmeticMachine')

local p = {}

local function articleFor(word)
	if word:sub(1,1):lower():match("[aeiou]") then
		return "an"
	end
	return "a"
end

local function expand(frame, title, arg)
	if frame.expandTemplate then
		return frame:expandTemplate{ title = title, args = { arg } }
	else
		return string.format("{{%s|%s}}", title, arg)
	end
end

function p.make(frame)
	local args = getArgs(frame)
	local name = args.name
	
	local rarity = info.getRarity{ name = name }
	local cType = info.getType{ name = name}
	local category = info.getCategory{ name = name }
	local collection = info.getCollection{ name = name }
	local added_date = args.added_date
	local added_in = args.added_in
	local unlock_method = args.unlock_method
	local stylePerk = args.style_perk
	
	local out = {}
	table.insert(out, string.format("'''%s''' is %s %s", name, articleFor(rarity), expand(frame, "Rarity", rarity .. "|Text")))

	if cType and cType ~= "Standard" then
		table.insert(out, " and " .. expand(frame, "CosmeticType", cType))
	end

	table.insert(out, string.format(" %s [[cosmetic]], found within the %s, that was introduced ", 
		expand(frame, "CosmeticCategory", category),
		expand(frame, "Collection", collection)
	))

	if added_date and added_date ~= "" then
		table.insert(out, "on " .. added_date)
	else
		table.insert(out, "in [[Patch " .. added_in .. "]]")
	end

	table.insert(out, ".")
	
	if info.isInCrateCollection{ name = name } == true then
		local typeToUse = cType
		if cType == "Standard" then
			typeToUse = ""
		end
		local blueprintIcon = string.format('[[File:%s%s Cosmetic Blueprint.png|20px|link=]]', rarity, " " .. typeToUse)
		table.insert(out, string.format(" Its %s blueprint form can be obtained in a number of ways:\n", blueprintIcon))
		table.insert(out, '*' .. crates.makeSentence{ name = name } .. "\n")
		if cType == "Standard" then
			local vendorPurchaseText = "* Purchasing from [[File:Head-Frank.png|20px|link=Frank]] [[Frank]] for "
			local crate = crates.getCrate{ name = name }
			if rarity == "Epic" then
				vendorPurchaseText = vendorPurchaseText .. "'''8x'''"
			elseif rarity == "Legendary" then
				vendorPurchaseText = vendorPurchaseText .. "'''18x'''"
			elseif rarity == "Mythic" then
				vendorPurchaseText = vendorPurchaseText .. "'''2x'''"
			end
			vendorPurchaseText = vendorPurchaseText .. string.format(" [[File:%s.png|20px|link=%s]] [[%s]]s\n", crate, crate, crate)
			table.insert(out, vendorPurchaseText)
		elseif cType == "Exclusive" then
			local vendorPurchaseText = "* Purchasing from [[File:Head-Big Cheese.png|20px|link=Big Cheese]] [[Big Cheese]] for "
			local crate = crates.getCrate{ name = name }
			if rarity == "Legendary" then
				vendorPurchaseText = vendorPurchaseText .. "'''5x'''"
			elseif rarity == "Mythic" then
				vendorPurchaseText = vendorPurchaseText .. "'''15x'''"
			end
			vendorPurchaseText = vendorPurchaseText .. string.format(" [[File:%s.png|20px|link=%s]] [[%s]]s\n", crate, crate, crate)
			table.insert(out, '*' .. vendorPurchaseText .. '\n')
		end
		table.insert(out, machine.makeSentences{ name = name, mode = list })
	elseif info.isArcaneGateCosmetic{ name = name} == true then
		local typeToUse = cType
		if cType == "Standard" then
			typeToUse = ""
		end
		local blueprintIcon = string.format('[[File:%s%s Cosmetic Blueprint.png|20px|link=]]', rarity, " " .. typeToUse)
		table.insert(out, string.format(" Its %s blueprint form can be obtained in a number of ways:\n", blueprintIcon))
		table.insert(out, "* '''8.3%''' chance from the [[File:Icon-Arcane Gate.png|20px|link=Arcane Gate]] [[Arcane Gate]]\n")
		table.insert(out, "* Purchasing from [[File:Head-Suspicious Stu.png|20px|link=Suspicious Stu]] [[Suspicious Stu]] for '''2x''' [[File:Arcane Gate Key.png|20px|link=Arcane Gate Key]] [[Arcane Gate Key]]s\n")
		table.insert(out, machine.makeSentences{ name = name, mode = "list" })
	else
		if args.unlock_method then
			table.insert(out, " " .. unlock_method)
		end
	end
	table.insert(out, '\n\n')
	
	if info.isColorable{ name = name } == true then
		local trophies = tonumber(info.getTrophiesAwarded{ name = name }) or 0
		local bonus = info.isBonusTrophies{ name = name }
		local trophyType = bonus and "Bonus" or "Style"
		table.insert(out, "It is {{Colorable}}, meaning players can apply [[Chroma Pack|chroma packs]] to it, allowing them to change its colour.")
		table.insert(out, '\n\n')
		table.insert(out, string.format("It can reward the player with up to %s: %s for owning it and an extra %s if all 4 [[Chroma Pack|chroma packs]] are applied to it.",
			expand(frame, string.format("%s Trophy", trophyType), trophies+10 .. "|text=yes"),
			expand(frame, string.format("%s Trophy", trophyType), trophies),
			expand(frame, string.format("%s Trophy", trophyType), 10)
		))
	else
		local trophies = tonumber(info.getTrophiesAwarded{ name = name }) or 0
		if trophies > 0 then
			local trophyType = info.isBonusTrophies{ name = name } and "Bonus" or "Style"
			table.insert(out, string.format("Owning it rewards the player with a total of %s.", expand(frame, string.format("%s Trophy", trophyType), trophies .. "|text=yes")))
			if info.isArcaneGateCosmetic{ name = name} == true then
				table.insert(out, string.format(" It also grants an extra perk tier of [[File:Perk-%s.png|24px]] [[%s]] while in the player's wardrobe.", stylePerk, stylePerk))
			end
		end
	end
	
--	if info.getReputationAmount{ name = name} > 0 then
--		table.insert(out, '\n\n')
--		table.insert(out, "Its token form can be scavenged for ")
--		table.insert(out, '\n\n')
--		table.insert(out, '==== Blueprint Recipe ====\n')
--		table.insert(out, string.format(
--			"'''%s''''s blueprint form must be crafted at the [[Blueprint Assembler]] into a cosmetic token before use.",
--			name
--		))
--		table.insert(out, '\nAlternatively, it can be scavenged for ')
--	end

	return table.concat(out)
end

return p