Module:Franchise List

local p = {}

local Franchise = require("Module:Franchise") local utilsPage = require("Module:UtilsPage") local utilsString = require("Module:UtilsString")

function p.GameLinks(frame) local args = frame.args local links = {} for i, gameCode in ipairs(Franchise.enumGames) do		if Franchise.type(gameCode) == args.type and not Franchise.isRemake(gameCode) then local page = utilsString.interpolate(args.link, {				article = Franchise.article(gameCode),				shortName = Franchise.shortName(gameCode),			}) if not args.ifExists or utilsPage.exists(page) then local link = string.format("%s", page, Franchise.display(gameCode)) local remakeLinks = {} for i, remake in ipairs(Franchise.remakes(gameCode)) do					local remakePage = utilsString.interpolate(args.link, {						article = Franchise.article(remake),						shortName = Franchise.shortName(remake),					}) if not args.ifExists or utilsPage.exists(remakePage) then -- Display only the suffix for remakes (remake name minus original name minus leading/trailing punctuation) -- e.g. Link's Awakening (Nintendo Switch) -> Nintendo Switch -- Hyrule Warriors: Definitive Edition -> Definitive Edition local remakeDisplay = string.gsub(Franchise.shortName(remake), Franchise.shortName(gameCode), "") remakeDisplay = string.gsub(remakeDisplay, "^[%s(:]+", "")						remakeDisplay = string.gsub(remakeDisplay, "%)$", "") local remakeLink = string.format("%s", remakePage, remakeDisplay) table.insert(remakeLinks, remakeLink) end end if #remakeLinks > 0 then remakeLinks = table.concat(remakeLinks, " ◦ ") link = string.format("%s (%s)", link, remakeLinks) end table.insert(links, link) end end end return table.concat(links, ", ") end

function p.Documentation(frame) return { GameLinks = { desc = "Creates a list of links for each game in Data:Franchise, for use in navbox templates.", wip = true, frameParamsOrder = {"type", "link", "ifExists"}, frameParams = { type = { required = true, enum = {"main", "spinoff"}, desc = "Indicates whether to generate links for main games or spin-off games.", },				link = { required = true, desc = " A templated article name used to generate a link for each game. Supported variables include:" .."\n* " .."\n* ", },				ifExists = { desc = "If present, a link is only created for a game if the corresponding page exists." },			},			cases = { {					args = { type = "main", link = "Enemies in ${shortName} ", },				},				{					args = { type = "spin-off", link = "Characters in ${shortName}", ifExists = " ", },				},			}		}	} end

return p