import { GameState, TableConfig, Action, PublicState } from "@pokertools/types"; import { Snapshot } from "../utils/serialization"; import { HandHistory, ExportOptions } from "@pokertools/types"; /** * Event listener callback type */ type EventListener = (action: Action, oldState: GameState, newState: GameState) => void; /** * Time provider function type for dependency injection */ type TimeProvider = () => number; /** * Main Poker Engine class * Wraps the pure reducer with a stateful API */ export declare class PokerEngine { private currentState; private listeners; private timeProvider; constructor(config: TableConfig, timeProvider?: TimeProvider); /** * Add a player to the table */ sit(seat: number, id: string, name: string, stack: number): void; /** * Remove a player from the table */ stand(id: string): void; /** * Deal a new hand */ deal(): void; /** * Execute an action * If action.timestamp is not provided, the engine will automatically set it */ act(action: Action): GameState; /** * Validate an action without executing it * Useful for UI state (enabling/disabling buttons) */ validate(action: Action): { valid: true; } | { valid: false; error: string; code?: string; }; /** * Reconcile local state with server state * Smoothly merges server updates into client engine */ reconcile(serverState: PublicState | GameState): void; /** * Optimistically execute an action and return the provisional state * Does not modify the engine's actual state */ optimisticAct(action: Action): GameState; /** * Undo last action */ undo(): boolean; /** * Get current game state (full, unmasked) */ get state(): GameState; /** * Get player view (masked) */ view(playerId?: string, version?: number): PublicState; /** * Get snapshot for serialization */ get snapshot(): Snapshot; /** * Restore from snapshot (static factory method) */ static restore(snapshot: Snapshot): PokerEngine; /** * Subscribe to state changes */ on(callback: EventListener): () => void; /** * Advance to next blind level (tournament) */ nextBlindLevel(): void; /** * Export hand history in specified format * * @param options Export format options * @returns Formatted hand history string */ history(options?: ExportOptions): string; /** * Get structured hand history object * * @returns Hand history object */ getHandHistory(): HandHistory; /** * Dispatch action through reducer */ private dispatch; /** * Validate configuration */ private validateConfig; /** * Create initial game state */ private createInitialState; } export {};