From 6f3c43aca62a7d33a19f14f6ad7c16891952673a Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Tue, 15 Sep 2026 19:55:21 -0400 Subject: fix: outstanding-stake ledger, owner backpressure, editor state preservation --- internal/casino/cards.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'internal/casino/cards.go') diff --git a/internal/casino/cards.go b/internal/casino/cards.go index f263eb6..b1c2cbb 100644 --- a/internal/casino/cards.go +++ b/internal/casino/cards.go @@ -69,10 +69,24 @@ func (s *shoe) shuffle() { } func (s *shoe) draw() card { - if s.shuffleAt > 0 && len(s.cards) <= int(float64(s.decks*52)*s.shuffleAt) { + if len(s.cards) == 0 { + // The shoe ran dry mid-round (only possible when the configured + // deck count is very small relative to the table): rebuild it + // rather than panic. The cut-card reshuffle itself happens + // between rounds via shuffleIfDue, never per draw. s.shuffle() } card := s.cards[len(s.cards)-1] s.cards = s.cards[:len(s.cards)-1] return card } + +// shuffleIfDue reshuffles the shoe once its remaining cards have fallen +// to the shuffleAt fraction (the cut card). It must be called at round +// boundaries only — shuffling between individual draws would let cards +// already dealt to hands reappear from the new shoe. +func (s *shoe) shuffleIfDue() { + if s.shuffleAt > 0 && len(s.cards) <= int(float64(s.decks*52)*s.shuffleAt) { + s.shuffle() + } +} -- cgit v1.2.3