diff options
Diffstat (limited to 'internal/casino/baccarat.go')
| -rw-r--r-- | internal/casino/baccarat.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/internal/casino/baccarat.go b/internal/casino/baccarat.go index fa54ac8..f4f5fbd 100644 --- a/internal/casino/baccarat.go +++ b/internal/casino/baccarat.go @@ -28,6 +28,9 @@ type baccaratPlayer struct { Participant lastBet int lastSpot string + // stakeID is the wallet handle of the wager record committed this + // round; the settlement returns it inside the payout. + stakeID string } func (p *baccaratPlayer) participantPtr() *Participant { return &p.Participant } @@ -128,7 +131,7 @@ func (t *baccaratTable) bet(name, spot string, amount int, wallet Wallet) []Even if err != nil { return []Event{t.private(name, walletErrorMessage(err))} } - p.HasBet, p.Wager, p.Wallet, p.lastBet, p.lastSpot = true, wager, wallet, amount, spot + p.HasBet, p.Wager, p.Wallet, p.lastBet, p.lastSpot, p.stakeID = true, wager, wallet, amount, spot, wager.ID events := []Event{t.playerAction(name, fmt.Sprintf("%s bets %d credits on %s.", name, amount, spot), fmt.Sprintf("You bet %d credits on %s.", amount, spot))} @@ -193,7 +196,7 @@ func (t *baccaratTable) deal() []Event { result, payout := settleBaccaratBet(p.lastSpot, p.Wager.Total, playerTotal, bankerTotal, t.Rules) payoutFailed := false if payout > 0 && p.Wallet != nil { - if err := p.Wallet.PayCredits(payout); err != 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 @@ -257,6 +260,9 @@ func (t *baccaratTable) resetRound() { t.phase = baccaratWaiting t.window.close() clearBets(t.players.participants()) + for _, p := range t.players.ordered() { + p.stakeID = "" + } } // markDisconnected removes the player from the table, forfeiting any wager |
