indian-rummy-core
Version:
High-performance Indian Rummy game logic library implemented in Rust with TypeScript bindings for Node.js applications
102 lines (99 loc) • 3.54 kB
TypeScript
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
/** JavaScript-compatible Card representation */
export interface JsCard {
rank: string
suit: string
}
/** JavaScript-compatible CompletedHandResult representation */
export interface JsCompletedHandResult {
completedHand: Array<JsCard>
remainingCards: Array<JsCard>
}
/** Calculate the penalty score for a hand */
export declare function score(hand: Array<JsCard>, designatedJoker?: JsCard | undefined | null): number
/** Check if a deck is complete (contains all 52 cards) */
export declare function isCompleteDeck(deck: Array<JsCard>): boolean
/** Check if a hand is completed according to Indian Rummy rules */
export declare function isCompletedHand(hand: Array<JsCard>, designatedJoker?: JsCard | undefined | null): boolean
/** Find a completed hand from a collection of 13 or more cards */
export declare function completedHandExists(cards: Array<JsCard>, designatedJoker?: JsCard | undefined | null): JsCompletedHandResult | null
/** JavaScript-compatible Player representation */
export interface JsPlayer {
id: string
name: string
hand: Array<JsCard>
}
/** JavaScript-compatible MoveType representation */
export const enum JsMoveType {
OpenCard = 'OpenCard',
CloseCard = 'CloseCard',
Fold = 'Fold'
}
/** JavaScript-compatible Move representation */
export interface JsMove {
playerId: string
moveType: JsMoveType
cardReceived?: JsCard
cardDiscarded?: JsCard
didClaimWin: boolean
}
/** JavaScript-compatible MoveResult representation */
export interface JsMoveResult {
isValid: boolean
isWin: boolean
winner?: string
scores: Record<string, number>
errorMessage?: string
}
/** JavaScript-compatible GameState representation */
export interface JsGameState {
players: Array<JsPlayer>
designatedJoker: JsCard
openPileTop?: JsCard
nextTurnPlayer: string
isComplete: boolean
winner?: string
finalScores: Record<string, number>
}
/** JavaScript-compatible IndianRummyGame representation */
export declare class JsIndianRummyGame {
/** Create a new Indian Rummy game */
constructor(playerIds: Array<string>, playerNames: Array<string>, nDecks: number)
/** Get the current game state */
getState(): JsGameState
/** Process a player move */
processMove(gameMove: JsMove): JsMoveResult
/** Check if a move is valid */
isValidMove(gameMove: JsMove): boolean
/** Get the top card from the open pile */
getTopOpenCard(): JsCard | null
/** Get the top card from the closed pile */
getTopClosedCard(): JsCard | null
/** Check if the game is complete */
isGameComplete(): boolean
/** Get player by ID */
getPlayer(playerId: string): JsPlayer | null
/** Serialize game to JSON */
serialize(): string
/** Deserialize game from JSON */
static deserialize(json: string): JsIndianRummyGame
}
/** JavaScript-compatible SyndicateGame representation */
export declare class JsSyndicateGame {
/** Create a new syndicate game */
constructor(playerIds: Array<string>)
/** Add a rummy game to the syndicate */
addRummyGame(game: JsIndianRummyGame): void
/** Get cumulative player points across all games */
getPlayerPoints(): Record<string, number>
/** Get leaderboard (players sorted by points, ascending) */
getLeaderboard(): Array<Array<string>>
/** Get number of games in the syndicate */
getGameCount(): number
/** Serialize syndicate to JSON */
serialize(): string
/** Deserialize syndicate from JSON */
static deserialize(json: string): JsSyndicateGame
}