aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/registry.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-19 03:15:59 -0400
committerhistoria <[not public]>2026-09-19 03:15:59 -0400
commit0e60567a7a0addb9421769ee7be7853bfa8788cb (patch)
tree7645112db0e4eae95b8a83c1e4f9aab38bede655 /internal/casino/registry.go
parentcc33072eced3d5460512c09c42ec4531c807d7af (diff)
downloadthehouseoficarus-0e60567a7a0addb9421769ee7be7853bfa8788cb.tar.gz
refactor: simplifcation, change how rooms are stored in player yaml, remove legacy code
Diffstat (limited to 'internal/casino/registry.go')
-rw-r--r--internal/casino/registry.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/internal/casino/registry.go b/internal/casino/registry.go
index 9a973d4..26acd8c 100644
--- a/internal/casino/registry.go
+++ b/internal/casino/registry.go
@@ -13,6 +13,12 @@ type tableGameDef struct {
validate func(TableConfig) error
// normalize applies this game's rule defaults to a table config.
normalize func(TableConfig) TableConfig
+ // ruleBlockName is the YAML rule block this game owns (for error messages),
+ // and hasRuleBlock reports whether that block carries any explicit value.
+ // Together they let TableConfig.Validate reject a block authored for a
+ // different game without a hand-maintained switch.
+ ruleBlockName string
+ hasRuleBlock func(TableConfig) bool
// new builds the game. It is called only after validate passes and the
// shared table config has been normalized.
new func(roomID int, cfg TableConfig, rng *rand.Rand) tableGame
@@ -26,15 +32,19 @@ var tableGames map[GameName]tableGameDef
func init() {
tableGames = map[GameName]tableGameDef{
GameBlackjack: {
- validate: validateBlackjackTable,
- normalize: normalizeBlackjackTable,
+ validate: validateBlackjackTable,
+ normalize: normalizeBlackjackTable,
+ ruleBlockName: "blackjack",
+ hasRuleBlock: hasBlackjackRuleBlock,
new: func(roomID int, cfg TableConfig, rng *rand.Rand) tableGame {
return newBlackjackTable(roomID, cfg, rng)
},
},
GameBaccarat: {
- validate: validateBaccaratTable,
- normalize: normalizeBaccaratTable,
+ validate: validateBaccaratTable,
+ normalize: normalizeBaccaratTable,
+ ruleBlockName: "baccarat",
+ hasRuleBlock: hasBaccaratRuleBlock,
new: func(roomID int, cfg TableConfig, rng *rand.Rand) tableGame {
return newBaccaratTable(roomID, cfg, rng)
},