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: Difference between revisions

From MCC Island Wiki
more more oops
mNo edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local expand = require("Module:Utils").expand
local info = require('Module:CosmeticInfo')
local info = require('Module:CosmeticInfo')
local crates = require('Module:CosmeticCrates')
local crates = require('Module:CosmeticCrates')
local machine = require('Module:CosmeticMachine')
local machine = require('Module:CosmeticMachine')
local recipe = require('Module:BlueprintRecipes')


local p = {}
local p = {}
Line 11: Line 14:
end
end
return "a"
return "a"
end
local function expand(frame, title, ...)
local args = {...}
local templateArgs = {}
for i, arg in ipairs(args) do
if type(arg) == "string" and arg:match("^[^=]+=.+$") then
local key, value = arg:match("^([^=]+)=(.+)$")
templateArgs[key] = value
else
templateArgs[i] = tostring(arg)
end
end
if frame.expandTemplate then
return frame:expandTemplate{ title = title, args = templateArgs }
else
local argString = {}
for i, arg in ipairs(args) do
table.insert(argString, tostring(arg))
end
return string.format("{{%s|%s}}", title, table.concat(argString, "|"))
end
end
end


Line 49: Line 28:
local unlock_method = args.unlock_method
local unlock_method = args.unlock_method
local stylePerk = args.style_perk or ""
local stylePerk = args.style_perk or ""
local image = args.image or name
local image = args.image or name .. '.png'
local out = {}
local out = {}
Line 90: Line 69:
end
end
vendorPurchaseText = vendorPurchaseText .. string.format(" [[File:%s.png|20px|link=%s]] [[%s]]s\n", crate, crate, crate)
vendorPurchaseText = vendorPurchaseText .. string.format(" [[File:%s.png|20px|link=%s]] [[%s]]s\n", crate, crate, crate)
table.insert(out, vendorPurchaseText)
table.insert(out, '* ' .. vendorPurchaseText)
elseif cType == "Exclusive" then
elseif cType == "Exclusive" then
local vendorPurchaseText = "Purchasing from [[File:Head-Big Cheese.png|20px|link=Big Cheese]] [[Big Cheese]] for "
local vendorPurchaseText = "Purchasing from [[File:Head-Big Cheese.png|20px|link=Big Cheese]] [[Big Cheese]] for "
Line 141: Line 120:
if info.isArcaneGateCosmetic{ name = name} == true then
if info.isArcaneGateCosmetic{ name = name} == true then
local perkIncrease = stylePerk:match("^([%w]+)") == "Expanded" and "+1" or "5%"
local perkIncrease = stylePerk:match("^([%w]+)") == "Expanded" and "+1" or "5%"
table.insert(out, string.format(" It also grants %s [[File:Perk-%s.png|24px]] [[%s]] while in the player's wardrobe.", perkIncrease, stylePerk, stylePerk))
table.insert(out, string.format("<br /> It also grants %s [[File:Perk-%s.png|24px]] [[%s]] while in the player's wardrobe.", perkIncrease, stylePerk, stylePerk))
end
end
end
end
Line 149: Line 128:
table.insert(out, '\n\n')
table.insert(out, '\n\n')
table.insert(out, string.format(
table.insert(out, string.format(
"Its token form can be scavenged in the [[Scavenger's Hideout]] for %s. The first %s donations also grant %s [[Royal Reputation]].",
"Its token form can be [[Scavenging|scavenged]] in the [[Scavenger's Hideout]] for %s.<br /> The first %s donations also grant %s [[Royal Reputation]].",
expand(frame, "CosmeticScavengeRewards", string.format("name=%s", name), "inline=true", "show_text=true"),
expand(frame, "CosmeticScavengeRewards", string.format("name=%s", name), "inline=true", "show_text=true"),
info.getDonationLimit{ name = name },
info.getDonationLimit{ name = name },
Line 164: Line 143:
expand(frame, "CosmeticScavengeRewards", "Blueprint", string.format("name=%s", name), "inline=true", "show_text=true")
expand(frame, "CosmeticScavengeRewards", "Blueprint", string.format("name=%s", name), "inline=true", "show_text=true")
))
))
local blueprintTableHeader = string.format('[[File:%s.png|25px|link=]] %s Token', image, name)
local blueprintTableHeader = string.format('[[File:%s|25px|link=]] %s Token', image, name)
local crafting_materials = "" or args.crafting_materials -- the empty string is a placeholder until something like Module:BlueprintRecipes is made
local crafting_materials = recipe.get(frame, collection, rarity)
if crafting_materials == "No recipe found" then
crafting_materials = args.crafting_materials or ""
end
table.insert(out, expand(frame, "Blueprint",
table.insert(out, expand(frame, "Blueprint",
string.format("item=%s", blueprintTableHeader), string.format("required_materials=%s", crafting_materials), string.format("rarity=%s", rarity)
string.format("item=%s", blueprintTableHeader), string.format("required_materials=%s", crafting_materials), string.format("rarity=%s", rarity)

Latest revision as of 12:03, 1 September 2025

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

local getArgs = require('Module:Arguments').getArgs
local expand = require("Module:Utils").expand

local info = require('Module:CosmeticInfo')
local crates = require('Module:CosmeticCrates')
local machine = require('Module:CosmeticMachine')
local recipe = require('Module:BlueprintRecipes')

local p = {}

local function articleFor(word)
	if word:sub(1,1):lower():match("[aeiou]") then
		return "an"
	end
	return "a"
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 or ""
	local added_in = args.added_in or ""
	local unlock_method = args.unlock_method
	local stylePerk = args.style_perk or ""
	local image = args.image or name .. '.png'
	
	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 ~= "" and " " or "") .. 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(frame) .. "\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, string.format(
			"It is %s, meaning players can apply [[Chroma Pack|chroma packs]] to it, allowing them to change its colour.",
			expand(frame, "Colorable")
		))
		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
				local perkIncrease = stylePerk:match("^([%w]+)") == "Expanded" and "+1" or "5%"
				table.insert(out, string.format("<br /> It also grants %s [[File:Perk-%s.png|24px]] [[%s]] while in the player's wardrobe.", perkIncrease, stylePerk, stylePerk))
			end
		end
	end
	
	if info.getReputationAmount{ name = name} > 0 then
		table.insert(out, '\n\n')
		table.insert(out, string.format(
			"Its token form can be [[Scavenging|scavenged]] in the [[Scavenger's Hideout]] for %s.<br /> The first %s donations also grant %s [[Royal Reputation]].",
			expand(frame, "CosmeticScavengeRewards", string.format("name=%s", name), "inline=true", "show_text=true"),
			info.getDonationLimit{ name = name },
			expand(frame, "Royal Reputation", info.getReputationAmount{ name = name})
		))
		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, string.format(
			'\nAlternatively, it can be scavenged for %s.\n',
			expand(frame, "CosmeticScavengeRewards", "Blueprint", string.format("name=%s", name), "inline=true", "show_text=true")
		))
		local blueprintTableHeader = string.format('[[File:%s|25px|link=]] %s Token', image, name)
		local crafting_materials = recipe.get(frame, collection, rarity)
		if crafting_materials == "No recipe found" then
			crafting_materials = args.crafting_materials or ""
		end
		table.insert(out, expand(frame, "Blueprint",
			string.format("item=%s", blueprintTableHeader), string.format("required_materials=%s", crafting_materials), string.format("rarity=%s", rarity)
		))
	end

	return table.concat(out)
end

return p