UNPKG

@idealic/poker-engine

Version:

Professional poker game engine and hand evaluator with built-in iterator utilities

256 lines 9.96 kB
/** Card ranks from lowest to highest */ export declare const ranks: readonly ["2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K", "A"]; /** Card rank type */ export type Rank = (typeof ranks)[number]; /** Card suits in alphabetical order */ export declare const suits: readonly ["c", "d", "h", "s"]; /** Card suit type */ export type Suit = (typeof suits)[number]; /** Card type representing a two-character string with rank and suit */ export type Card = `${Rank}${Suit}`; /** Card type representing an unknown card */ export type UnknownCard = `??`; /** Valid card type */ export type ValidCard = Card | UnknownCard; /** Represents a player seat mapping */ export interface PlayerSeat { id?: string; name: string; originalSeat: number; seat: number; } /** * Represents a poker game variant. * FT - Fixed-limit Texas hold 'em * NT - No-limit Texas hold 'em * NS - No-limit short-deck hold 'em * PO - Pot-limit Omaha hold 'em * FO/8 - Fixed-limit Omaha hold 'em high/low-split eight or better * F7S - Fixed-limit seven card stud * F7S/8 - Fixed-limit seven card stud high/low-split eight or better * FR - Fixed-limit razz * N2L1D - No-limit deuce-to-seven lowball single draw * F2L3D - Fixed-limit deuce-to-seven lowball triple draw * FB - Fixed-limit badugi */ export type Variant = 'FT' | 'NT' | 'NS' | 'PO' | 'FO/8' | 'F7S' | 'F7S/8' | 'FR' | 'N2L1D' | 'F2L3D' | 'FB'; /** Variants that use no-limit/pot-limit betting structure */ export type NoLimitVariant = 'NT' | 'NS' | 'PO' | 'N2L1D'; /** Variants that use fixed-limit betting structure */ export type FixedLimitVariant = 'FT' | 'FO/8' | 'F7S' | 'F7S/8' | 'FR' | 'F2L3D' | 'FB'; /** Variants that use stud structure with bring-in */ export type StudVariant = 'F7S' | 'F7S/8' | 'FR'; /** Base game interface with common required fields */ export interface BaseGame { /** Name of the venue where the hand was played */ venue?: string; /** Table number or identifier */ table?: string; /** Club ID for PokerStars Home Game */ clubId?: number; /** Hand number */ hand?: number; /** Unique identifier for the game */ id?: string; /** Random seed for deterministic card dealing */ seed?: number; /** Name of person who recorded the hand */ author?: string; /** Name of the poker event/tournament */ event?: string; /** Tournament blind/ante level number */ level?: number; /** URL relevant to the event or venue */ url?: string; /** Currency code in ISO 4127 format (e.g. 'USD', 'EUR') */ currency?: string; /** Total number of seats at the table */ seatCount?: number; /** Array of actual seat numbers for each player */ seats?: number[]; /** Absolute amount taken by the house from the pot */ rake?: number; /** Total pot size including rake */ totalPot?: number; /** Rake percentage used to calculate rake when absolute amount is not provided (0.05 = 5%) */ rakePercentage?: number; /** Whether short stacks can only win what they contributed to antes */ anteTrimming?: boolean; /** Time limit per action in seconds */ timeLimit?: number; /** Array of ante amounts for each player position */ antes: number[]; /** Array of blind or straddle amounts for each player position */ blindsOrStraddles: number[]; /** Array of starting stack amounts for each player position */ startingStacks: number[]; /** Array of player names in clockwise order from first to act */ players: string[]; /** Final stack amounts for each player after the hand */ finishingStacks?: number[]; /** Time bank amounts in seconds for each player */ timeBanks?: number[]; /** Array of player winnings in the hand */ winnings?: number[]; /** Array of actions in the hand */ actions: Action[]; /** Timestamp of the game start */ timestamp?: number; /** Year the hand was played */ year?: number; /** Month the hand was played (1-12) */ month?: number; /** Day of month the hand was played (1-31) */ day?: number; /** Time in ISO format YYYY-MM-DDTHH:mm:ss */ time?: string; /** IANA timezone name (e.g. 'America/Toronto') */ timeZone?: string; /** Country where the hand was played */ country?: string; /** Region/state/province where the hand was played */ region?: string; /** City where the hand was played */ city?: string; /** Postal/zip code of the venue */ postalCode?: string; /** Physical address of the venue */ address?: string; /** Array of player ids local to the venue */ _venueIds?: string[]; /** Array of hero ids local to the venue */ _heroIds?: (string | null)[]; /** Manager uid */ _managerUid?: string; /** Croupier id */ _croupierId?: string; /** Array of indices for players who are sitting out */ _inactive?: number[]; /** Array of dead blinds */ _deadBlinds?: number[]; /** [key: `_${string}`]: unknown; */ [key: `_${string}`]: unknown; } /** No-limit/pot-limit game */ export interface NoLimitGame extends BaseGame { variant: NoLimitVariant; minBet: number; smallBet?: never; bigBet?: never; bringIn?: never; } /** Fixed-limit game */ export interface FixedLimitGame extends BaseGame { variant: Exclude<FixedLimitVariant, StudVariant>; minBet?: never; smallBet: number; bigBet: number; bringIn?: never; } /** Stud game */ export interface StudGame extends BaseGame { variant: StudVariant; minBet?: never; smallBet: number; bigBet: number; bringIn: number; } export type { Hand } from './Hand'; /** Represents a serialized action type in the PHH format */ export declare const FOLD = "f"; export declare const CALL_CHECK = "cc"; export declare const CALL_BET_RAISE = "cbr"; export declare const SHOW_MUCK = "sm"; export declare const DEAL_BOARD = "db"; export declare const DEAL_HAND = "dh"; export declare const UNKNOWN = "?"; export type ActionType = typeof FOLD | typeof CALL_CHECK | typeof CALL_BET_RAISE | typeof SHOW_MUCK | typeof DEAL_BOARD | typeof DEAL_HAND | typeof UNKNOWN | typeof ACTION_MESSAGE; /** Represents a betting street in poker */ export type Street = 'preflop' | 'flop' | 'turn' | 'river'; export declare const Streets: readonly ["preflop", "flop", "turn", "river"]; /** Action constants */ export declare const ACTION_DEAL_BOARD = "db"; export declare const ACTION_DEAL_HOLE = "dh"; export declare const ACTION_STAND_PAT_OR_DISCARD = "sd"; export declare const ACTION_POST_BRING_IN = "pb"; export declare const ACTION_FOLD = "f"; export declare const ACTION_CHECK_CALL = "cc"; export declare const ACTION_COMPLETE_BET_RAISE = "cbr"; export declare const ACTION_SHOW_MUCK = "sm"; export declare const ACTION_MESSAGE = "m"; /** Represents a single action in PHH format */ export type ActionCommand = `d ${DealerActionType} ${string}` | `p${number} ${PlayerActionType}` | `p${number} ${typeof ACTION_CHECK_CALL} ${number}` | `p${number} ${typeof ACTION_COMPLETE_BET_RAISE} ${number}` | `p${number} ${typeof ACTION_STAND_PAT_OR_DISCARD} ${string} ` | `p${number} ${typeof ACTION_SHOW_MUCK} ${string}` | `p${number} ${typeof ACTION_MESSAGE} ${string}`; export type Action = `${ActionCommand}${ActionComment}` | string; export type ActionComment = '' | ` #${string}`; /** Union type of dealer actions */ export type DealerActionType = typeof ACTION_DEAL_BOARD | typeof ACTION_DEAL_HOLE; /** Union type of player actions */ export type PlayerActionType = typeof ACTION_STAND_PAT_OR_DISCARD | typeof ACTION_POST_BRING_IN | typeof ACTION_FOLD | typeof ACTION_CHECK_CALL | typeof ACTION_COMPLETE_BET_RAISE | typeof ACTION_SHOW_MUCK | typeof ACTION_MESSAGE; /** * @instructions Never remove properties or comments without a clear reason. Comments should stay with their properties. */ export type { Game } from './Game'; export type { CommandName } from './Command'; /** Represents a player at the table */ export interface Player { /** Player's name or identifier */ name: string; /** Current chip stack available to bet */ stack: number; /** Amount won in the hand */ winnings: number; /** Position at the table (0-based index) */ position: number; /** Hole cards dealt to the player */ cards: ValidCard[]; /** Whether the player has folded this hand */ hasFolded: boolean; /** Whether the player has acted in current betting round */ hasActed: boolean; /** Amount bet in the current betting round. Reset to 0 when moving to next street or hand completes. */ currentBet: number; /** Total amount bet across all betting rounds in the hand. Persists until hand completion for accurate pot contribution tracking. */ totalBet: number; /** Total amount bet in this betting round. Reset to 0 when moving to next street or hand completes. */ roundBet: number; /** Whether the player has gone all-in */ isAllIn: boolean; /** Whether the player has shown their cards */ hasShownCards: boolean; /** Rake the player has paid in the hand */ rake: number; /** Whether the player is sitting out */ isInactive: boolean; } export interface HandFixture { title: string; description: string; input: string; output: Hand; game: Game; } /** Region information for OCR */ export interface Region { /** Top-left x coordinate */ x: number; /** Top-left y coordinate */ y: number; /** Width of the region */ width: number; /** Height of the region */ height: number; } /** Generic type for JSON AST with OCR region information */ export type JSONAST<T> = T extends (infer U)[] ? { region: Region; value: JSONAST<U>[]; } : T extends object ? { region: Region; value: { [K in keyof T]: JSONAST<T[K]>; }; } : { region: Region; value: T; }; //# sourceMappingURL=types.d.ts.map