UNPKG

@xpressit/winning-poker-hand-rank

Version:
23 lines (22 loc) 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.rankHands = void 0; const calcBestHand_1 = require("./calcBestHand"); const card_1 = require("./card"); const toCombination_1 = require("./toCombination"); const toOutputMadeHand = (madeHand) => { return madeHand.map((c) => (0, card_1.toPlayingCard)(c)); }; const rankHands = (gameType, board, hands) => { return hands.map((hand) => { const bestHand = (0, calcBestHand_1.calcBestHand)(gameType, hand.map((c) => (0, card_1.toCard)(c)), board.map((c) => (0, card_1.toCard)(c))); return { rank: bestHand.rank, combination: (0, toCombination_1.toCombination)(gameType, bestHand.rank), madeHand: toOutputMadeHand(bestHand.madeHand), unused: bestHand.unused.map((c) => (0, card_1.toPlayingCard)(c)), low: bestHand.low ? { rank: bestHand.low.rank, madeHand: toOutputMadeHand(bestHand.low.madeHand) } : undefined, }; }); }; exports.rankHands = rankHands;