Module:Exp Game

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 = games or {} games = utilsTable.intersection(Franchise.enum(true), games) -- sorts the games, removes duplicates and invalid values games = utilsTable.difference(games, {""}) -- removes empty string if present if #games == 0 then return "" end games = utilsTable.map(games, p.printGame) games = table.concat(games, " | ") return "("..games..")" end

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

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

return p