UNPKG

@xpressit/winning-poker-hand-rank

Version:
27 lines (26 loc) 986 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.calcBestHand = void 0; const cardRank_1 = require("./cardRank"); const calcBestHand = (gameType, pocketCards, communityCards) => { const getHandRanker = () => { if (gameType === 'short_deck') { return cardRank_1.rankShortDeckHand; } if (gameType === 'omaha' || gameType === 'omaha_hi_lo') { return cardRank_1.rankOmahaHand; } return cardRank_1.rankTexasHand; }; const shouldLow = gameType === 'omaha_hi_lo'; const rankHand = getHandRanker(); const cards = [...pocketCards, ...communityCards]; const { rank, madeHand, low } = rankHand(pocketCards, communityCards, shouldLow); return { rank, madeHand, unused: cards.filter((c) => !madeHand.find((mc) => mc === c)), low: low ? { rank: low.rank, madeHand: low.madeHand } : undefined, }; }; exports.calcBestHand = calcBestHand;