From 0b0b25222b3131ada79ff78c28eb8bf07d977deb Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Tue, 15 Sep 2026 15:35:52 -0400 Subject: feat: single-owner game state, transactional lifecycle, durable money on server stop --- internal/casino/types.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'internal/casino/types.go') diff --git a/internal/casino/types.go b/internal/casino/types.go index 4d5159a..75d041b 100644 --- a/internal/casino/types.go +++ b/internal/casino/types.go @@ -2,9 +2,6 @@ package casino import "fmt" -// maxBetUnlimited is the MaxBet sentinel meaning "no wager cap". -const maxBetUnlimited = int(^uint(0) >> 1) - // betRangeText describes the accepted wager range; the unlimited sentinel is // rendered as "no maximum" instead of a machine-sized integer. func betRangeText(minBet, maxBet int) string { @@ -126,8 +123,10 @@ func (c MachineConfig) Normalize() MachineConfig { if c.MinBet <= 0 { c.MinBet = 1 } + // An unset MaxBet defaults to the economy's bounded cap; the explicit + // unlimited sentinel is still honored for authored configurations. if c.MaxBet <= 0 { - c.MaxBet = maxBetUnlimited + c.MaxBet = DefaultMaxBet } if c.SpinTicks <= 0 { c.SpinTicks = 2 @@ -152,7 +151,7 @@ func (c TableConfig) Normalize() TableConfig { c.MinBet = 1 } if c.MaxBet <= 0 { - c.MaxBet = maxBetUnlimited + c.MaxBet = DefaultMaxBet } return c } @@ -164,8 +163,14 @@ type Wager struct { } type Wallet interface { - Wager(amount int) (Wager, bool) - PayCredits(amount int) + // Wager debits the stake durably. ErrInsufficientFunds is a normal + // rejected bet; ErrWalletPersistence means the debit could not be made + // durable and the game must not proceed as if the bet succeeded. + Wager(amount int) (Wager, error) + // PayCredits pays a settlement durably, returning an error when the + // credit could not be persisted (the game must not report a win that + // is not durable). + PayCredits(amount int) error } type EventType string -- cgit v1.2.3