import type { GamePlugin } from "./types";

const games = new Map<string, GamePlugin>();

export const gameRegistry = {
    register(plugin: GamePlugin) {
        if (games.has(plugin.slug)) {
            throw new Error(`Game "${plugin.slug}" is already registered`);
        }
        games.set(plugin.slug, plugin);
    },
    get(slug: string): GamePlugin | undefined {
        return games.get(slug);
    },
    list(): GamePlugin[] {
        return Array.from(games.values());
    },
};
