@idealic/poker-engine
Version:
Professional poker game engine and hand evaluator with built-in iterator utilities
38 lines • 1.85 kB
TypeScript
import type { Action, Hand, Game, ValidCard } from '../types';
export declare function cloneState(state: Game): Game;
/**
* Creates a sanitized copy of the table state where cards are hidden for players who haven't shown them.
* This is used when sharing table state with players to maintain game integrity.
* Cards are only visible if:
* 1. The player has shown their cards (hasShownCards is true)
* 2. The hand is complete and the player hasn't folded
* @param table The table state to sanitize
* @param playerPosition Optional position of the player viewing the table. If provided, their cards will be visible.
*/
export declare function sanitizeTable(game: Game, playerPosition?: number): Game;
/** @todo: implement this */
export declare function formatAction(action: Action): string;
/**
* Applies an action to a game state.
* @param game - The game state to apply the action to
* @param action - The action to apply
* @returns The updated game state
*/
export declare function applyGameAction(hand: Hand, action: Action): Hand;
/**
* Tries to merge two game states, assuming they are from the same table, have common players and are in the same hand.
* @param oldGame - The first game state
* @param newGame - The second game state
* @returns The merged game state
*/
export declare function mergeGames(oldHand: Hand, newHand: Hand): Hand;
export declare function getGameId(hand: Hand): string;
/**
* Replaces the cards of a player in the game actions.
* @param game - The game to modify
* @param playerId - The ID of the player to replace cards for
* @param playerName - The name of the player to replace cards for
* @param cards - The new cards to replace with
*/
export declare function replacePlayerCards(hand: Hand, playerId: string, playerName: string, cards: ValidCard[]): Hand;
//# sourceMappingURL=state.d.ts.map