Skip to content

splitPots

splitPots(contributions, folded): Pot[]

Defined in: cards/pots.ts:36

Splits the chips each seat put in this hand into a main pot and side pots. contributions[seat] is that seat's total for the hand and folded[seat] whether it folded. Pots come main pot first; each later pot has a higher contribution level and fewer eligible seats.

Rules: every seat's chips go into the pots up to its contribution, folded or not; a pot's eligible seats are the unfolded seats that contributed at least its level; neighbouring levels with the same eligible seats merge into one pot; chips above the highest unfolded contribution (only possible when a folded seat put in more) go into the last pot. The amounts always sum to the total contributed, and no chips means no pots. If every contributing seat folded, the result is one pot with no eligible seats.

// Seat 0 all-in for 50, seats 1 and 2 put in 200, seat 3 folded after 20.
splitPots([50, 200, 200, 20], [false, false, false, true]);
// [{ amount: 170, eligible: [0, 1, 2] }, { amount: 300, eligible: [1, 2] }]

readonly number[]

readonly boolean[]

Pot[]