import config, { type Game } from "@/config"; const { games: GAMES } = config; export function getGame(id: string) { const game = GAMES.find((game) => game.universeId === id); return game; } export function getGames(ids: string[]) { return GAMES.filter((game) => ids.includes(game.id)); } export function parseIncludedGames(games: string | null | undefined): Game[] { if (!games) return GAMES; const parsed = games.split(","); const acceptedIds = GAMES.map((game) => game.id); const unmatched = parsed.filter((id) => !acceptedIds.includes(id)); if (unmatched.length > 0) throw new Error(`Invalid game ID: ${unmatched.join(", ")}`); const matched = parsed.filter((id) => acceptedIds.includes(id.toLowerCase())); return getGames(matched); }