UNPKG

shoehive

Version:

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

32 lines (31 loc) 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TableFactory = void 0; const Table_1 = require("./Table"); const EventTypes_1 = require("../events/EventTypes"); /** * Factory class for creating tables. * This class is responsible for creating new tables and emitting events when tables are created. * * It is exposed as part of the createGameServer function in the index.ts file, and can be used to create new tables. * Client functionality for this is already natively handled by the `lobby` command namespace. ([Client Commands](/api/generated/#client_command_types)) */ class TableFactory { constructor(eventBus) { this.eventBus = eventBus; } /** * Creates a new table with the specified number of seats and maximum seats per player. * Emits a TABLE_EVENTS.CREATED event when the table is created. * * @param totalSeats - The total number of seats at the table. * @param maxSeatsPerPlayer - The maximum number of seats a player can occupy. * @returns The newly created table. */ createTable(totalSeats, maxSeatsPerPlayer) { const table = new Table_1.Table(this.eventBus, totalSeats, maxSeatsPerPlayer); this.eventBus.emit(EventTypes_1.TABLE_EVENTS.CREATED, table); return table; } } exports.TableFactory = TableFactory;