UNPKG

shoehive

Version:

WebSocket-based multiplayer game framework for real-time, event-driven gameplay

73 lines (72 loc) 2.04 kB
import { EventBus } from "../events/EventBus"; import { Table } from "./Table"; import { TableFactory } from "./TableFactory"; export interface GameDefinition { id: string; name: string; description: string; minPlayers: number; maxPlayers: number; defaultSeats: number; maxSeatsPerPlayer: number; options?: Record<string, any>; tableRelevantPlayerAttributes?: string[]; lobbyRelevantPlayerAttributes?: string[]; } export declare class GameManager { private games; private tables; private tablesByGame; private eventBus; private tableFactory; constructor(eventBus: EventBus, tableFactory: TableFactory); /** * Sets up event listeners for the game manager. * This listens for table creation and table emptying. */ private setupEventListeners; /** * Registers a game definition. * * @param gameDefinition The game definition to register. */ registerGame(gameDefinition: GameDefinition): void; /** * Unregisters a game definition. * * @param gameId The ID of the game to unregister. */ unregisterGame(gameId: string): void; /** * Removes a table from the game manager. * * @param tableId The ID of the table to remove. */ removeTable(tableId: string): void; /** * Gets all available games. * * @returns An array of all game definitions. */ getAvailableGames(): GameDefinition[]; /** * Gets a game definition by its ID. * * @param gameId The ID of the game * @returns The game definition, or undefined if not found */ getGameDefinition(gameId: string): GameDefinition | undefined; /** * Gets all tables for a game. * * @param gameId The ID of the game. * @returns An array of tables for the game. */ getTablesForGame(gameId: string): Table[]; /** * Gets all tables in the game manager. * * @returns An array of all tables. */ getAllTables(): Table[]; }