From 6d9908b29c8187196d23b126b1165c7e0bd0fc76 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Thu, 1 Oct 2026 19:30:38 -0400 Subject: fix: casino pai gow sorting, universal unbet, table/rules split, remove solo timers --- internal/casino/unbet_test.go | 59 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 internal/casino/unbet_test.go (limited to 'internal/casino/unbet_test.go') 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 " 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) + } +} -- cgit v1.2.3