aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/baccarat.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/casino/baccarat.go')
-rw-r--r--internal/casino/baccarat.go45
1 files changed, 15 insertions, 30 deletions
diff --git a/internal/casino/baccarat.go b/internal/casino/baccarat.go
index b762b6f..cf8a289 100644
--- a/internal/casino/baccarat.go
+++ b/internal/casino/baccarat.go
@@ -51,7 +51,7 @@ func newBaccaratTable(roomID int, cfg TableConfig, rng *rand.Rand) *baccaratTabl
}
func (t *baccaratTable) menuEvent(name string) Event {
- return t.betMenuEvent(name, MenuBaccaratBet, []MenuCommand{
+ return t.betMenuEvent(name, []MenuCommand{
{Command: "bet <amount>", Desc: "Place a wager (min/max accepted)"},
{Command: "bet <amount> on player|banker|tie", Desc: "Wager on a specific outcome"},
{Command: "stop", Desc: "Leave the table"},
@@ -161,45 +161,30 @@ func (t *baccaratTable) deal() []Event {
player, banker := playTableau(t.shoe)
playerTotal, bankerTotal := baccaratTotal(player), baccaratTotal(banker)
round := t.event("New baccarat hand!", true)
- round.Baccarat = t.snapshot(player, banker)
+ round.Snapshot = t.snapshot(player, banker)
events := []Event{round, t.event(baccaratOutcomeMessage(playerTotal, bankerTotal), true)}
for _, p := range t.players.ordered() {
if !p.HasBet {
continue
}
result, payout, settleErr := settleBaccaratBet(p.lastSpot, p.Wager.Total, playerTotal, bankerTotal, t.Rules)
- // A payout-overflow error means the win could not be computed; treat
- // it like an unpersisted payout so the win is never announced as paid
- // (blackjack handles the same case identically).
- payoutFailed := settleErr != nil
- if !payoutFailed && payout > 0 && p.Wallet != nil {
- if err := p.Wallet.PayStakeCover(payout, []string{p.stakeID}); err != nil {
- // The payout could not be made durable; recovery will
- // re-apply the owed amount from the open journal record.
- // Do not announce the win as paid and leave the stakes
- // open for recovery to settle.
- payoutFailed = true
- }
- }
+ // The shared settlement path pays before announcing, leaves the
+ // stake open on any failure (recovery re-applies the owed payout),
+ // and resolves it only once durable.
+ payoutFailed := settleStakeOutcome(p.Wallet, payout, []string{p.stakeID}, settleErr)
+ publicResult, privateResult := baccaratResultMessages(p.Name, result, payout)
if payoutFailed {
- publicResult, _ := baccaratResultMessages(p.Name, result, payout)
- settlement := t.playerAction(p.Name, publicResult, payoutFailedMessage())
- if result == "win" {
+ privateResult = payoutFailedMessage()
+ }
+ settlement := t.playerAction(p.Name, publicResult, privateResult)
+ if result == "win" {
+ if p.lastSpot == baccaratSpotTie {
+ settlement.Color = "casino_jackpot_win"
+ } else {
settlement.Color = "casino_big_win"
}
- events = append(events, settlement)
- } else {
- publicResult, privateResult := baccaratResultMessages(p.Name, result, payout)
- settlement := t.playerAction(p.Name, publicResult, privateResult)
- if result == "win" {
- if p.lastSpot == baccaratSpotTie {
- settlement.Color = "casino_jackpot_win"
- } else {
- settlement.Color = "casino_big_win"
- }
- }
- events = append(events, settlement)
}
+ events = append(events, settlement)
if p.Wallet != nil && !payoutFailed {
// The round resolved; the stakes are no longer outstanding.
p.Wallet.ResolveStakes()