import { GameRoomData } from '../shared/gameRoomStore'; import { Context } from 'yawr'; import { CurrentPlayerValidation } from '../shared/interface'; import { IServer } from './interface'; import { GameOptions } from '../shared/standardActions'; export type ComponentConstructor = (id: number) => [string, never]; export type Component = [string, never]; type ComponentsMap = { [id: string]: never; }; interface GameRoom { data: GameRoomData; joinedPlayers: Map; components: ComponentsMap; } /** * Creates a validation helper bound to the current user and game room. * This is used to validate whether a user can perform actions as a specific player in the game. * (a user can only move as a player if they have taken that seat in the game room). * * @param ctx - Request context. * @param gameId - Target game id. * @returns Validation callbacks used by game actions. */ export declare function createCurrentPlayerValidation(ctx: Context, gameId: number): CurrentPlayerValidation; export declare function canUserMoveAsPlayerInGame(userId: string, gameId: number, playerId: number): boolean; /** * Returns a component stored for a game room. * * @typeParam T - Expected component type. * @param gameId - Game id. * @param type - Component key. * @returns The component value. * @throws Error When the game or component does not exist. */ export declare function getGameComponent(gameId: number, type: string): T; /** * Creates a game room and joins the caller as the first connected member. * * @param ctx - Request context. * @param options - Room options including player count. * @param type - Game type identifier. * @param components - Component constructors. * @param timeout - Empty-room timeout in milliseconds. * @returns Created game room data. */ export declare function createGameRoomAndJoin(ctx: Context, options: GameOptions, type: string, components: ComponentConstructor[], timeout: number): GameRoomData; /** * Closes and removes a game room from memory. * * @param gameId - Game id. * @returns The removed game room, or undefined if it does not exist. */ export declare function closeGame(gameId: number): GameRoom | undefined; /** * Creates and stores a new game room instance. * Will fill instance components by calling each constructor with the game id. * * @param options - Room options including player count. * @param type - Game type identifier. * @param components - Component constructors. * @param timeout - Optional empty-room timeout in milliseconds. * @returns The created game room with data and initialized components. */ export declare function createGameRoom(options: GameOptions, type: string, components: ComponentConstructor[], timeout?: number): GameRoom; /** * Registers game-related RPC handlers on the server. * * @param server - Server abstraction used to register handlers. */ export declare function registerGames(server: IServer): void; export {};