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 Game2"]) 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, 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 Game2"] = { purpose = "", format = "inline", params = { [1] = {				name = "games", placeholder = "game1, game2, ..., gameN", type = "string", required = true, enum = Franchise.enum, desc = "A comma-separated list of one or more game codes.", split = true, }		},		examples = { {"OoT"}, {"OoT, MM"}, {"MM, OoT, MM, OoT"}, {},			{""},			{"fakeGame"}, {"OoT, fakeGame, MM"} }	} }

return p