import { GameRoomData, GameRoomState, UserInfo } from '../shared/gameRoomStore'; import { Store } from '../shared/interface'; import { BaseClient } from './baseClient'; import { GameOptions } from '../shared/standardActions'; import { IGameRoomClient } from './interface'; /** * The `GameRoomClient` class extends the `BaseClient` and provides functionality * for interacting with a game room server. It manages the state of the game room, * handles WebSocket events, and provides methods for creating, joining, and managing * game rooms and seats. */ export declare class GameRoomClient extends BaseClient implements IGameRoomClient { /** * The ID of the current game room. */ gameId: number | undefined; /** * The password for the current game room, if applicable. */ gamePassword: string | undefined; /** * Information about the current user. */ userInfo: UserInfo | undefined; /** * The Redux-like store that manages the state of the game room. */ store: Store; /** * Constructs a new `GameRoomClient` instance. * @param path - The WebSocket path to connect to. Defaults to `/ws`. */ constructor(path?: string); /** * Gets the seat index of the current user. * @returns The seat index of the user. */ seatOf(): number; /** * Checks if the current user currecntly occupies a specific seat. * @param index - The index of the seat to check. * @returns `true` if the user can occupy the seat, otherwise `false`. */ haveSeat(index: number): boolean; /** * Checks if a specific seat is empty. * @param index - The index of the seat to check. * @returns `true` if the seat is empty, otherwise `false`. */ isSeatEmpty(index: number): boolean; /** * Starts the client by connecting to the server and authorizing the user. * @param token - The authorization token for the user. * @returns A promise that resolves to `true` if the client started successfully, otherwise `false`. */ start(token: string | undefined): Promise; /** * Disconnects the client from the server. */ disconnect(): void; /** * Reconnects the client to the server and reinitializes the game room state. * @param token - The authorization token for the user. */ reconnect(token: string | undefined): Promise; /** * Creates a new game room. * @param game - The id of the game. * @param options - The options for the game room. * @returns A promise that resolves to a tuple containing the game room ID and password. */ createRoom(game: string, options: GameOptions): Promise<[number, string | undefined]>; /** * Joins an existing game room. * @param gameId - The ID of the game room to join. * @param password - The password for the game room, if required. * @returns A promise that resolves to the game room ID. */ join(gameId: number, password?: string): Promise; /** * Takes a specific seat in the game room. * @param seat - The index of the seat to take. */ takeSeat(seat: number): Promise; /** * Leaves a specific seat in the game room. * @param seat - The index of the seat to leave. */ leaveSeat(seat: number): Promise; /** * Takes the first available seat in the game room. * @returns A promise that resolves to the index of the seat taken. */ takeAvailableSeat(): Promise; /** * Closes the current game room. */ close(): Promise; /** * Retrieves the current state of the game room from server. * @returns A promise that resolves to the game room state data. */ getState(): Promise; /** * Retrieves the current state from the store. * @returns The current state of the game room. * @private */ private state; }