aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/types.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-15 15:35:52 -0400
committerhistoria <[not public]>2026-09-15 15:35:52 -0400
commit0b0b25222b3131ada79ff78c28eb8bf07d977deb (patch)
tree2ceaef5203595044f66a8f00064cd8e017f8f48d /internal/casino/types.go
parent396c3facb8287b9a34076cae8f3d7b300d366d99 (diff)
downloadthehouseoficarus-0b0b25222b3131ada79ff78c28eb8bf07d977deb.tar.gz
feat: single-owner game state, transactional lifecycle, durable money on server stop
Diffstat (limited to 'internal/casino/types.go')
-rw-r--r--internal/casino/types.go19
1 files changed, 12 insertions, 7 deletions
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