shoehive
Version:
WebSocket-based multiplayer game framework for real-time, event-driven gameplay
93 lines (92 loc) • 2.47 kB
TypeScript
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, unknown>;
tableRelevantPlayerAttributes?: string[];
lobbyRelevantPlayerAttributes?: string[];
relevantTableAttributes?: 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: GameDefinition;
}): void;
/**
* Unregisters a game definition.
*
* @param gameId The ID of the game to unregister.
*/
unregisterGame({ gameId }: {
gameId: string;
}): void;
/**
* Removes a table from the game manager.
*
* @param tableId The ID of the table to remove.
*/
removeTable({ tableId }: {
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 }: {
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 }: {
gameId: string;
}): Table[];
/**
* Gets a table by its ID.
*
* @param tableId The ID of the table.
* @returns The table, or undefined if not found.
*/
getTableById({ tableId }: {
tableId: string;
}): Table | undefined;
/**
* Gets all tables in the game manager.
*
* @returns An array of all tables.
*/
getAllTables(): Table[];
}