July 25, 2020

👭 Knight Challenge #11 👬

Want to try your hand at these challenges? There's a couple of things you can do!
From writing, to research, to images, find your preferred way to contribute with our eleventh theme: Couples!

Latest Announcements

Module:Exp Game

From Zelda Wiki, the Zelda encyclopedia
Jump to: navigation, search

Documentation for this module may be created at Module:Exp Game/Documentation

local Franchise = require("Module:Franchise")
local utilsArg = require("Module:UtilsArg")
local utilsMarkup = require("Module:UtilsMarkup")
local utilsTable = require("Module:UtilsTable")

local p = {}

-- Main function called by Template:Exp Game
function p.Main(frame)
	local args, err = utilsArg.parse(frame:getParent().args, p.Templates["Exp Game"])
	local result = p.printGames(args.games)
	if err then
		result = result .. utilsMarkup.categories(err.categories)
	end
	return result
end

function p.printGames(games)
	games = utilsTable.difference(games or {}, {""}) -- removes empty string if present
	if #games == 0 then
		return ""
	end
	games = utilsTable.map(games, p.printGame)
	games = table.concat(games, " | ") -- &#124 is the HTML entity for the pipe character. Needs to be entered like this in order to not break tables and such
	return "<sup>("..games..")</sup>"
end

function p.printGame(game)
	local result = utilsMarkup.tooltip(game, Franchise.shortName(game), "highlight")
	return utilsMarkup.bold(result)
end

p.Templates = {
	["Exp Game"] = {
		purpose = "{{Exp Game/Purpose}}",
		format = "inline",
		params = {
			[1] = {
				name = "games",
				placeholder = "game1, game2, ..., gameN",
				type = "string",
				required = true,
				enum = Franchise.enum({ includeSeries = true }),
				desc = "A comma-separated list of one or more [[Data:Franchise|game codes]].",
				split = true,
				sortAndRemoveDuplicates = true,
			}
		},
		examples = {
			{"OoT"},
			{"Series, OoT, MM"},
			{"MM, OoT, MM, OoT"},
			{},
			{""},
			{"fakeGame"},
			{"OoT, fakeGame, MM"}
		}
	}
}

return p