diff options
| author | historia <[not public]> | 2026-09-15 19:55:21 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-15 19:55:21 -0400 |
| commit | 6f3c43aca62a7d33a19f14f6ad7c16891952673a (patch) | |
| tree | 0b0665ef624ef442df87ec7131129aaecc3420bd /internal/casino/cards.go | |
| parent | cd95de60364aba8f5bdf8ec86f7234a9903eacc8 (diff) | |
| download | thehouseoficarus-6f3c43aca62a7d33a19f14f6ad7c16891952673a.tar.gz | |
fix: outstanding-stake ledger, owner backpressure, editor state preservation
Diffstat (limited to 'internal/casino/cards.go')
| -rw-r--r-- | internal/casino/cards.go | 16 |
1 files changed, 15 insertions, 1 deletions
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() + } +} |
