diff --git a/JoshHeaps.Net/wwwroot/js/casino/holdem/state.js b/JoshHeaps.Net/wwwroot/js/casino/holdem/state.js index 67b4a4e..666af2f 100644 --- a/JoshHeaps.Net/wwwroot/js/casino/holdem/state.js +++ b/JoshHeaps.Net/wwwroot/js/casino/holdem/state.js @@ -159,7 +159,20 @@ const HoldemState = { return ((fromIndex + delta) % count + count) % count; }, + // The button passes to the next player, not the next chair. Moving it one seat at + // a time parks it on empty chairs — with four players spread around ten seats it + // sits on nobody most hands — and that isn't only untidy: position and blinds are + // supposed to come round to each player at the same rate, and they don't if the + // button is rotating past chairs nobody is sitting in. advanceButton(state) { + for (let step = 1; step <= state.seatCount; step++) { + const index = this.nextSeatIndex(state, state.dealerSeatIndex, step); + if (state.seats[index].inHand) { + state.dealerSeatIndex = index; + return; + } + } + // Nobody is dealt in; move it along anyway so it doesn't look stuck. state.dealerSeatIndex = this.nextSeatIndex(state, state.dealerSeatIndex, 1); },