From 516fd29da423432ef6dfded21a984f1d15dcab1a Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Mon, 5 Oct 2026 17:31:50 -0400 Subject: fix: slop casino and economy fixes --- internal/casino/machine.go | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'internal/casino/machine.go') diff --git a/internal/casino/machine.go b/internal/casino/machine.go index 0733384..93ab8aa 100644 --- a/internal/casino/machine.go +++ b/internal/casino/machine.go @@ -357,7 +357,9 @@ func (m *Machine) finishSpin() []Event { m.phase = machineSpinning m.spin = generateSlotSpinWithProfile(m.rng, m.spinBet, m.profile) m.reel, m.clock, m.suspense = 0, 0, false - events = append(events, m.public(fmt.Sprintf("%d free spins remain.", m.freeSpins))...) + if m.freeSpins > 0 { + events = append(events, m.public(fmt.Sprintf("%d free spins remain.", m.freeSpins))...) + } } else { m.inFreeSpins = false if !payFailed && m.player.Wallet != nil { @@ -382,9 +384,34 @@ func (m *Machine) leave(name string) []Event { if m.phase != machineReady { return m.private("You're in the middle of a spin!") } + bank := int(m.featureBank) + wallet := m.player.Wallet + stakeFailed := m.stakeFailed m.resetSeat() - return []Event{{RoomID: m.RoomID, TableID: m.Config.ID, Type: EventLeft, Player: name, + events := []Event{{RoomID: m.RoomID, TableID: m.Config.ID, Type: EventLeft, Player: name, Message: fmt.Sprintf("%s stands up from the slots machine.", name), PrivateMessage: "You stand up from the slot machine.", PrivateTo: name, Color: "casino_action", Public: true}} + // Banked free-spin winnings must not vanish when the player stands up: + // pay them like markDisconnected/refundAll do, or report the forfeiture. + if bank > 0 && wallet != nil { + switch { + case stakeFailed: + events = append(events, Event{RoomID: m.RoomID, TableID: m.Config.ID, Type: EventResult, + PrivateTo: name, Player: name, + PrivateMessage: fmt.Sprintf("Your %d credits of banked free-spin winnings were forfeited because the round could not be persisted.", bank), + Color: "casino_action", Public: false}) + case wallet.PayCredits(bank) != nil: + events = append(events, Event{RoomID: m.RoomID, TableID: m.Config.ID, Type: EventResult, + PrivateTo: name, Player: name, + PrivateMessage: fmt.Sprintf("Your %d credits of free-spin winnings could not be persisted; they were forfeited.", bank), + Color: "casino_action", Public: false}) + default: + events = append(events, Event{RoomID: m.RoomID, TableID: m.Config.ID, Type: EventResult, + PrivateTo: name, Player: name, + PrivateMessage: fmt.Sprintf("The house settles your %d banked free-spin winnings.", bank), + Color: "casino_action", Public: false}) + } + } + return events } // resetSeat frees the machine, discarding any in-flight spin and autobet -- cgit v1.2.3