UNPKG

poker-odds-calc-test

Version:
41 lines (40 loc) 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class Player { constructor(seat, Table, hand = null) { this.seat = seat; this.Table = Table; this.hand = null; if (Array.isArray(hand)) this.setHand(hand); } setHand(hand) { const game = this.Table.getGame(); if ((game.isTexasHoldem() || game.isSixPlusTexasHoldem()) && hand.length !== 2) throw new Error("A Texas hold'em hand must contain exactly 2 cards!"); if (game.isOmaha() && hand.length !== 5) throw new Error("An Omaha hand must contain exactly 5 cards!"); this.hand = hand.map(c => { return this.Table.getDeck().getCards().find(card => card.toString() === c).setOwner(this); }); return this; } getHand() { if (this.hand === null) return null; return this.hand.map(card => card.toString()).join(""); } inHand() { return this.hand !== null; } getCards() { return this.hand; } isEmpty() { return !this.inHand(); } getSeat() { return this.seat; } } exports.default = Player;