diff options
Diffstat (limited to 'internal/casino/baccarat_test.go')
| -rw-r--r-- | internal/casino/baccarat_test.go | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/internal/casino/baccarat_test.go b/internal/casino/baccarat_test.go index 2cb932e..fc12e4b 100644 --- a/internal/casino/baccarat_test.go +++ b/internal/casino/baccarat_test.go @@ -108,6 +108,9 @@ func TestBaccaratSettlement(t *testing.T) { if result, payout := settleBaccaratBet(baccaratSpotBanker, 100, 4, 6, rules); result != "win" || payout != 195 { t.Fatalf("banker win: result=%s payout=%d, want win/195 (5%% commission)", result, payout) } + if result, payout := settleBaccaratBet(baccaratSpotBanker, 1, 4, 6, rules); result != "win" || payout != 1 { + t.Fatalf("banker win on bet 1: result=%s payout=%d, want win/1 (commission rounds up)", result, payout) + } if result, payout := settleBaccaratBet(baccaratSpotTie, 100, 7, 7, rules); result != "win" || payout != 900 { t.Fatalf("tie win: result=%s payout=%d, want win/900 (8:1)", result, payout) } @@ -141,7 +144,7 @@ func TestBaccaratSoloBetDealsImmediately(t *testing.T) { if w.paid != 200 { t.Fatalf("payout=%d, want 200 (stake + 1:1)", w.paid) } - if table.phase != baccaratWaiting || table.participants["alice"].HasBet { + if table.phase != baccaratWaiting || table.players.get("alice").HasBet { t.Fatalf("table did not reset after deal: phase=%s", table.phase) } // The round event carries a snapshot of both hands and the bets. @@ -205,7 +208,7 @@ func TestBaccaratBettingIgnoresDisconnected(t *testing.T) { table := newBaccaratTestTable(TableConfig{ID: "baccarat", Game: GameBaccarat, MaxPlayers: 2}) table.join("alice") table.join("bob") - table.markDisconnected("bob") + table.markDisconnected("bob") // removes bob, not just marks him forceShoe(table, card{rank: "5"}, card{rank: "4"}, // player 9 card{rank: "2"}, card{rank: "3"}, // banker 5 @@ -213,7 +216,35 @@ func TestBaccaratBettingIgnoresDisconnected(t *testing.T) { w := &testWallet{credits: 100} events := table.bet("alice", baccaratSpotPlayer, 10, w) if !hasMessage(events, "New baccarat hand!") { - t.Fatalf("disconnected player stalled the round: %+v", events) + t.Fatalf("removed player stalled the round: %+v", events) + } +} + +func TestBaccaratDisconnectFreesSeat(t *testing.T) { + table := newBaccaratTestTable(TableConfig{ID: "baccarat", Game: GameBaccarat, MaxPlayers: 2}) + table.join("alice") + table.join("bob") + w := &testWallet{credits: 100} + table.bet("alice", baccaratSpotPlayer, 10, w) // opens betting, alice has bet + // Bob disconnects without betting — his seat is freed and his non-wager + // is skipped; the round resolves on the next tick for the remaining + // connected bettor. + events := table.markDisconnected("bob") + if !hasMessage(events, "bob stands up") { + t.Fatalf("disconnect event missing: %+v", events) + } + if table.players.count() != 1 { + t.Fatalf("bob's seat was not freed: count=%d", table.players.count()) + } + // Alice's bet should resolve on the next tick (only connected bettor + // remains, allBet is true). + forceShoe(table, + card{rank: "5"}, card{rank: "4"}, // player 9 + card{rank: "2"}, card{rank: "3"}, // banker 5 + ) + tickEvents := table.tick() + if !hasMessage(tickEvents, "New baccarat hand!") { + t.Fatalf("tick after removal did not resolve the round: %+v", tickEvents) } } |
