diff options
| author | historia <[not public]> | 2026-08-03 16:42:59 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-08-03 16:42:59 -0400 |
| commit | adda27dba5bf7bf1dee62159f0cbc0bd90734751 (patch) | |
| tree | 2a68c0bad42c3561cfcd7a32eee52f7ff7eb14f9 /internal/casino/machine.go | |
| parent | fe15f2ffeb5685b056650a61aa0e23965ef51e95 (diff) | |
| download | thehouseoficarus-adda27dba5bf7bf1dee62159f0cbc0bd90734751.tar.gz | |
fix: blackjack game formatting
Diffstat (limited to 'internal/casino/machine.go')
| -rw-r--r-- | internal/casino/machine.go | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/internal/casino/machine.go b/internal/casino/machine.go index 887e154..0ee4cde 100644 --- a/internal/casino/machine.go +++ b/internal/casino/machine.go @@ -64,7 +64,7 @@ func (m *Machine) join(name string) []Event { return m.menuEvents("You resume your place at the slot machine.") } -func (m *Machine) setBet(name string, amount int) []Event { +func (m *Machine) setBet(name string, amount int, wallet Wallet) []Event { m.mu.Lock() defer m.mu.Unlock() if !m.owns(name) { @@ -79,8 +79,9 @@ func (m *Machine) setBet(name string, amount int) []Event { if amount < m.Config.MinBet || amount > m.Config.MaxBet { return m.private(fmt.Sprintf("Slot machine bets must be between %d and %d.", m.Config.MinBet, m.Config.MaxBet)) } - m.bet = amount - return m.menuEvents(fmt.Sprintf("Your slot machine bet is set to %d.", amount)) + return m.beginSpinLocked(name, amount, wallet, + fmt.Sprintf("%s sets the bet to %d and pulls the lever.", name, amount), + fmt.Sprintf("Bet set to %d. You pull the lever on the slots machine.", amount)) } func (m *Machine) start(name string, wallet Wallet) []Event { @@ -98,15 +99,22 @@ func (m *Machine) start(name string, wallet Wallet) []Event { if m.bet <= 0 { return m.private("Set a wager first with 'bet <amount>'.") } - if _, ok := wallet.Wager(m.bet); !ok { + return m.beginSpinLocked(name, m.bet, wallet, + fmt.Sprintf("%s pulls the lever on the slots machine.", name), + "You pull the lever on the slots machine.") +} + +func (m *Machine) beginSpinLocked(name string, amount int, wallet Wallet, publicMessage, privateMessage string) []Event { + if _, ok := wallet.Wager(amount); !ok { return m.private("You don't have enough chips and credits for that bet.") } - m.spinBet = m.bet + m.bet = amount + m.spinBet = amount m.player.Wallet = wallet m.spin = generateSlotSpinWithProfile(m.rng, m.spinBet, m.profile) m.reel, m.clock, m.suspense = 0, 0, false m.phase = machineSpinning - return m.playerAction(fmt.Sprintf("%s pulls the lever on the slots machine.", name), "You pull the lever on the slots machine.") + return m.playerAction(publicMessage, privateMessage) } func (m *Machine) enableAutoBet(name string, wallet Wallet) []Event { |
