From 0e60567a7a0addb9421769ee7be7853bfa8788cb Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Sat, 19 Sep 2026 03:15:59 -0400 Subject: refactor: simplifcation, change how rooms are stored in player yaml, remove legacy code --- internal/casino/registry.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'internal/casino/registry.go') 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) }, -- cgit v1.2.3