This is the main module for the following templates:
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, " | ") -- | 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