@idealic/poker-engine
Version:
Professional poker game engine and hand evaluator with built-in iterator utilities
74 lines • 2.55 kB
TypeScript
import type { NoLimitGame, FixedLimitGame, StudGame } from './types';
import { parseHand } from './formats/pokerstars';
/**
* Represents a poker game according to the PHH (Poker Hand History) format specification.
*
* Required fields are used for:
* 1. Initial state construction:
* - variant
* - antes
* - blindsOrStraddles
* - startingStacks
* - players
*
* 2. State progression:
* - actions
*
* 3. Variant-specific required fields:
* - minBet (required for NT, NS, PO, N2L1D)
* - smallBet and bigBet (required for FT, FO/8, F7S, F7S/8, FR, F2L3D, FB)
* - bringIn (required for F7S, F7S/8, FR)
*/
export type Hand = NoLimitGame | FixedLimitGame | StudGame;
/**
* Hand constructor/guard function that creates a validated Hand object.
* Acts as a factory function with sensible defaults and validation.
*
* @param props - Partial Hand properties to create a complete Hand
* @returns A validated Hand object
*
* @example
* const hand = Hand({
* variant: 'NT',
* players: ['Alice', 'Bob'],
* startingStacks: [1000, 1000],
* blindsOrStraddles: [10, 20],
* minBet: 20
* });
*/
export declare function Hand(props: Partial<Hand>): Hand;
/**
* Hand namespace for methods that operate on Hand objects.
*/
export declare namespace Hand {
/**
* Parse a hand from string format (PokerStars or JSON)
* @param input - String representation of the hand
* @param format - Format type ('pokerstars' or 'json')
* @returns Parsed Hand object
*/
const parse: typeof parseHand;
/**
* Export a hand with an optional player perspective, censoring cards appropriately
* @param hand - The hand to export
* @param playerId - Optional player ID for perspective (shows only their cards and shown cards)
* @returns The hand with cards censored from the player's perspective
*/
function output(hand: Hand, playerId?: string): Hand;
/**
* Check if two hands are equal
* @param oldHand - First hand to compare
* @param newHand - Second hand to compare
* @returns True if hands are equal, false otherwise
*/
function isHandsEqual(oldHand: Hand, newHand: Hand): boolean;
/**
* Serialize a hand to string format
* @param input - Hand to serialize
* @param format - Output format ('pokerstars' or 'json')
* @returns Serialized hand as string
*/
function serialize(input: Hand, format?: 'pokerstars' | 'json'): string;
}
import './formats/custom';
//# sourceMappingURL=Hand.d.ts.map