Module:Franchise List

local p = {} local h = {}

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

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 link = args[gameCode] or args.link local page = h.interpolate(link, {				article = Franchise.article(gameCode),				shortName = Franchise.shortName(gameCode),			}) if 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 link = args[remake] or args.link local remakePage = h.interpolate(link, {						article = Franchise.article(remake),						shortName = Franchise.shortName(remake),					}) if 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), "") local useItalics = true remakeDisplay = string.gsub(remakeDisplay, "^[%s(:]+", "")						if string.find(remakeDisplay, "%)$") then remakeDisplay = string.gsub(remakeDisplay, "%)$", "")						else							remakeDisplay = ""..remakeDisplay..""						end						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 h.interpolate(formatStr, vars) return string.gsub(formatStr, "\$%S+", function(templateVar)		return vars[templateVar:sub(2)]	end) end

function p.Documentation(frame) return { GameLinks = { desc = "Creates a list of links for each game in Data:Franchise, for use in navbox templates.", frameParamsOrder = {"type", "link"}, 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* ", }			},			cases = { {					args = { type = "main", link = "Enemies in $shortName", },				},				{					args = { type = "spin-off", link = "Characters in $shortName", },				},				{					desc = "Overriding  for specific entries", args = { type = "spin-off", link = "Dungeons in $shortName", LCT = "Stages in $shortName", }				}			}		}	} end

return p