diff options
| author | historia <[not public]> | 2026-09-05 16:31:22 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-05 16:31:22 -0400 |
| commit | f4ea40c4b3589104dfaced3481ba19c5735889ae (patch) | |
| tree | 66ead13206e52a65e64d6ba5d1576b63954682e9 /internal/casino/blackjack.go | |
| parent | 9a716a7d2ce514f452b425caedc1a9a15cde09f0 (diff) | |
| download | thehouseoficarus-main.tar.gz | |
Diffstat (limited to 'internal/casino/blackjack.go')
| -rw-r--r-- | internal/casino/blackjack.go | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/internal/casino/blackjack.go b/internal/casino/blackjack.go index 90d6feb..442d4a2 100644 --- a/internal/casino/blackjack.go +++ b/internal/casino/blackjack.go @@ -111,18 +111,21 @@ func (t *blackjackTable) join(name string) []Event { func (t *blackjackTable) leave(name string) []Event { t.mu.Lock() defer t.mu.Unlock() - if !t.players.has(name) { + p := t.players.get(name) + if p == nil { return nil } - if t.phase != blackjackWaiting { + // A wager is committed for the round in flight; everyone else may stand + // up whenever they like. Non-bettor removal reuses the disconnect path, + // which fixes up the active seat while a round is in flight. + if p.HasBet { return []Event{t.private(name, "You're in the middle of a blackjack round!")} } - t.players.remove(name) - events := []Event{t.playerAction(name, fmt.Sprintf("%s stands up.", name), "You stand up.")} - if t.players.count() == 0 { - events = append(events, t.event("The blackjack table closes.", true)) + events := t.markDisconnectedLocked(name) + if len(events) == 0 { + return nil } - return events + return append(events, t.private(name, "You stand up.")) } func (t *blackjackTable) bet(name, spot string, amount int, wallet Wallet) []Event { @@ -142,7 +145,7 @@ func (t *blackjackTable) bet(name, spot string, amount int, wallet Wallet) []Eve return []Event{t.private(name, "You have already bet this round.")} } if amount < t.Config.MinBet || amount > t.Config.MaxBet { - return []Event{t.private(name, fmt.Sprintf("Blackjack bets must be between %d and %d.", t.Config.MinBet, t.Config.MaxBet))} + return []Event{t.private(name, fmt.Sprintf("Blackjack bets must be %s.", betRangeText(t.Config.MinBet, t.Config.MaxBet)))} } wager, ok := wallet.Wager(amount) if !ok { @@ -683,6 +686,10 @@ func blackjackResultMessages(name, result string, payout int) (string, string) { func (t *blackjackTable) markDisconnected(name string) []Event { t.mu.Lock() defer t.mu.Unlock() + return t.markDisconnectedLocked(name) +} + +func (t *blackjackTable) markDisconnectedLocked(name string) []Event { index := t.players.indexOf(name) if index < 0 { return nil |
