Module:InfoboxGameBlocks

local Franchise = require("Module:Franchise") local utilsError = require("Module:UtilsError") local utilsString = require("Module:UtilsString") local utilsTable = require("Module:UtilsTable")

local p = {}

function p._CreateBlocks(frame) local args = utilsTable.clone(frame:getParent.args) -- cloning so that we can mutate this table local blocks = {} for _, game in ipairs(Franchise.enum({ includeSeries = true })) do		if not utilsString.isEmpty(args[game]) then table.insert(blocks, {game = Franchise.display(game), content = args[game]}) end if args[game] then args[game] = nil -- remove valid games one by one as they are processed end end -- Any games that remain at this point are invalid local invalidCodes = utilsTable.keys(args) if #invalidCodes > 0 then utilsError.warn("The following game codes are invalid: ") return p.CreateBlocks(blocks) .. ""	end return p.CreateBlocks(blocks) end function p.CreateBlocks(blocks) local result = "" local count = 1 for key, block in ipairs(blocks) do		if count > 1 then result = result .. " "		end result = result .. "''' " .. block["game"] .. " ''' " .. block["content"] count = count + 1 end return result end

return p