diff options
| author | historia <[not public]> | 2026-10-01 19:30:38 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-10-01 19:30:38 -0400 |
| commit | 6d9908b29c8187196d23b126b1165c7e0bd0fc76 (patch) | |
| tree | ddbc02357ed92646b801687b90b1a06c71a15d71 /internal/casino/unbet_test.go | |
| parent | 8a94f21bd47c0a00bc415395232dba22fa958837 (diff) | |
| download | thehouseoficarus-6d9908b29c8187196d23b126b1165c7e0bd0fc76.tar.gz | |
fix: casino pai gow sorting, universal unbet, table/rules split, remove solo timers
Diffstat (limited to 'internal/casino/unbet_test.go')
| -rw-r--r-- | internal/casino/unbet_test.go | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/internal/casino/unbet_test.go b/internal/casino/unbet_test.go new file mode 100644 index 0000000..d132b58 --- /dev/null +++ b/internal/casino/unbet_test.go @@ -0,0 +1,59 @@ +package casino + +import "testing" + +// The single unbet command must take back every pre-round wager at every +// table game; games no longer accept per-target "unbet <spot>" spellings. +func TestUnbetRefundsPreRoundWagersEveryGame(t *testing.T) { + t.Run("baccarat", func(t *testing.T) { + tab := newBaccaratTestTable(TableConfig{ID: "bac", Game: GameBaccarat, BettingTicks: 10}) + tab.join("a") + tab.join("b") + w := &testWallet{chips: 100} + tab.bet("a", "banker", 10, w) + if events := tab.action("a", "unbet"); !hasMessage(events, "take back") { + t.Fatalf("unbet: %+v", events) + } + if w.chips+w.paid != 100 || len(w.open) != 0 { + t.Fatalf("wallet not refunded: chips=%d paid=%d open=%d", w.chips, w.paid, len(w.open)) + } + }) + t.Run("blackjack", func(t *testing.T) { + tab := newBlackjackTable(1, TableConfig{ID: "bj", Game: GameBlackjack, BettingTicks: 10, + Blackjack: BlackjackConfig{Decks: 8, ActionTicks: 10}}, newTestRand()) + tab.join("a") + tab.join("b") + w := &testWallet{chips: 100} + tab.bet("a", "", 10, w) + if events := tab.action("a", "unbet"); !hasMessage(events, "take back") { + t.Fatalf("unbet: %+v", events) + } + if w.chips+w.paid != 100 || len(w.open) != 0 { + t.Fatalf("wallet not refunded: chips=%d paid=%d open=%d", w.chips, w.paid, len(w.open)) + } + }) + t.Run("roulette", func(t *testing.T) { + tab := rouletteFixture() + tab.join("a") + tab.join("idle") + w := &testWallet{chips: 100} + tab.bet("a", "red", 10, w) + if events := tab.action("a", "unbet"); !hasMessage(events, "take back") { + t.Fatalf("unbet: %+v", events) + } + if w.chips+w.paid != 100 || len(w.open) != 0 { + t.Fatalf("wallet not refunded: chips=%d paid=%d open=%d", w.chips, w.paid, len(w.open)) + } + if tab.phase != phaseWaiting { + t.Fatalf("empty roulette table did not reset: %s", tab.phase) + } + }) +} + +func TestUnbetWithNothingCommitted(t *testing.T) { + tab := newBaccaratTestTable(TableConfig{ID: "bac", Game: GameBaccarat, BettingTicks: 10}) + tab.join("a") + if events := tab.action("a", "unbet"); !hasMessage(events, "Nothing to take back") { + t.Fatalf("unbet with no wager: %+v", events) + } +} |
