Module:API info/flavor ambox

From Warcraft Watch Secrets
Revision as of 20:45, 14 July 2025 by imported>Ketho (mists)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:API info/flavor ambox/doc

local flavor_module = require("Module:API_info/flavor")
local patch_module = require("Module:API_info/patch")
local group_module = require("Module:API_info/group")
local m = {}

local info = {
	vanilla = {
		border = "yellow",
		image = "[[File:WoW Classic logo.png|128px|Classic Era|link=]]",
	},
	mists = {
		border = "blue",
		image = "[[File:WoW_MoP_Classic_logo.png|80px|Mists of Pandaria Classic|link=]]",
	},
	none = {
		border = "red",
		image = "[[File:Inv mushroom 11.png|32px|shroom|link=]]",
		type = "'''This no longer exists on any flavor of the game.'''",
	}
}

function m:GetAmbox(f, name)
	local flags, mainline, vanilla, mists = flavor_module:GetFlavorInfo(f.args.t, name)
	local added = patch_module:GetPatches(f.args.t, name)
	-- dont show ambox when group infobox is already shown
	if #added > 0 and not group_module:GetData(name) then
		local template = {title = "Ambox"}
		if (vanilla or mists) and not mainline then
			template.args = info[mists and "mists" or vanilla and "vanilla"]
			local expansions = {}
			if mists then
				table.insert(expansions, "''[[World_of_Warcraft:_Mists_of_Pandaria_Classic|Mists Classic]]''")
			end
			if vanilla then
				table.insert(expansions, "''[[Classic Era]]''")
			end
			template.args.type = string.format("'''This API only exists in %s.'''", table.concat(expansions, " and "))
		elseif not flags then
			template.args = info.none
		end
		if template.args then
			template.args.style = "width: auto; margin-left: 0.8em;"
			local expanded = f:expandTemplate(template)
			if template.args == info.none then
				expanded = "[[Category:API functions/Noflavor]]\n"..expanded
			end
			return expanded
		end
	end
end

return m