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.go32
1 files changed, 25 insertions, 7 deletions
diff --git a/internal/casino/baccarat.go b/internal/casino/baccarat.go
index 68f363e..e34518f 100644
--- a/internal/casino/baccarat.go
+++ b/internal/casino/baccarat.go
@@ -47,11 +47,16 @@ func newBaccaratTable(roomID int, cfg TableConfig, rng *rand.Rand) *baccaratTabl
}
func (t *baccaratTable) menuEvent(name string) Event {
- return t.betMenuEvent(name, []MenuCommand{
- {Command: "bet <amount>", Desc: "Place a wager (min/max accepted)"},
- {Command: "bet <amount> on " + t.Rules.betChoices(), Desc: "Wager on a specific outcome (one wager per round)"},
- {Command: "stop", Desc: "Leave the table"},
- })
+ commands := []MenuCommand{}
+ if p := t.players.get(name); p != nil && p.lastBet > 0 {
+ commands = append(commands, MenuCommand{Command: "bet", Desc: fmt.Sprintf("Repeat %d on %s (also: rebet)", p.lastBet, p.lastSpot)}, MenuCommand{Command: "bet <amount>", Desc: "Change amount; keep " + p.lastSpot})
+ }
+ commands = append(commands, MenuCommand{Command: fmt.Sprintf("bet %d banker", t.Config.MinBet), Desc: "Choose banker (b), player (p), or tie (t); min/max accepted"}, MenuCommand{Command: "bet <amount> on " + t.Rules.betChoices(), Desc: "One wager per round; 'on' is optional"}, MenuCommand{Command: "stop", Desc: "Leave; during a round, leave afterward"}, MenuCommand{Command: "table / sitout", Desc: "Check the table / skip betting until you rejoin"})
+ e := t.betMenuEvent(name, commands)
+ if p := t.players.get(name); p != nil {
+ e.Menu.Repeat = p.lastBet > 0
+ }
+ return e
}
func (t *baccaratTable) join(name string) []Event {
@@ -111,6 +116,7 @@ func (t *baccaratTable) bet(name, spot string, amount int, wallet Wallet) []Even
if err != nil {
return []Event{t.private(name, walletErrorMessage(err))}
}
+ p.SittingOut = false
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),
@@ -132,6 +138,14 @@ func (t *baccaratTable) tick() []Event {
}
func (t *baccaratTable) action(name, action string) []Event {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+ if events, handled := t.controlLocked(name, action); handled {
+ if t.phase == baccaratBetting && allBet(t.players.participants()) {
+ return append(events, t.deal()...)
+ }
+ return events
+ }
return []Event{t.private(name, "That game has no player actions.")}
}
@@ -171,11 +185,14 @@ func (t *baccaratTable) deal() []Event {
// stake pending on any failure, so a refund can never be paid on top
// of a payout that was not durable.
payoutFailed := settleStakeOutcome(p.Wallet, payout, []string{p.stakeID}, settleErr)
- publicResult, privateResult := baccaratResultMessages(p.Name, result, payout)
+ publicResult, _ := baccaratResultMessages(p.Name, result, payout)
+ privateResult := resultText(result, p.Wager.Total, payout)
if payoutFailed {
privateResult = payoutFailedMessage()
+ publicResult = p.Name + "’s settlement is pending recovery."
}
settlement := t.playerAction(p.Name, publicResult, privateResult)
+ settlement.ShowBalance = !payoutFailed
if result == "win" {
if p.lastSpot == baccaratSpotTie {
settlement.Color = "casino_jackpot_win"
@@ -190,8 +207,9 @@ func (t *baccaratTable) deal() []Event {
// pending by an earlier failed payout, which must stay refundable.
}
t.resetRound()
+ events = append(events, t.finishControlsLocked()...)
for _, p := range t.players.ordered() {
- if p.Connected {
+ if p.Connected && !p.SittingOut {
events = append(events, t.menuEvent(p.Name))
}
}