Skip to content

awardPots

awardPots(pots, scores, options?): number[]

Defined in: cards/pots.ts:90

Pays out pots. scores[seat] is that seat's hand strength (for poker, evaluateHand(cards).rank), higher wins, or null for a seat with no hand. Each pot goes to its eligible seats with the highest score; returns the chips won per seat (length scores.length). With one unfolded seat left, give it any score.

Ties split a pot evenly. Chips that do not divide go one at a time to the tied winners in seat order, starting from firstSeat (default 0) and wrapping, so with the default the first winner by seat number gets the odd chip. For the usual "left of the button" rule, pass { firstSeat: (button + 1) % seats }.

Throws a RangeError when a pot with chips has no eligible seat with a score.

const pots = splitPots(state.contributions, state.folded);
const scores = state.seats.map((s) => (s.folded ? null : evaluateHand([...s.hole, ...board]).rank));
const won = awardPots(pots, scores); // won[seat] chips for each seat

readonly Pot[]

readonly (number | null)[]

number

number[]