aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/cards.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/casino/cards.go')
-rw-r--r--internal/casino/cards.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/casino/cards.go b/internal/casino/cards.go
index 27da8aa..2d53b4a 100644
--- a/internal/casino/cards.go
+++ b/internal/casino/cards.go
@@ -73,6 +73,14 @@ func (s *shoe) remaining() int { return len(s.cards) }
func (s *shoe) draw() card {
if len(s.cards) == 0 {
+ if s.decks <= 0 {
+ // A synthetic, explicitly-scripted shoe (tests) has no decks to
+ // rebuild from and no cards left; return a visibly-invalid sentinel
+ // card rather than panicking. Production shoes always have Decks >
+ // 0 (Normalize), so this only surfaces a test fixture that drew
+ // past its script.
+ return card{rank: "?", suit: "?"}
+ }
// Shuffle-through: if the shoe runs out mid-round it is rebuilt from
// all decks, so a card already dealt this round can reappear. This
// matches real blackjack, where an exhausted shoe is shuffled through