diff options
Diffstat (limited to 'internal/casino/registry.go')
| -rw-r--r-- | internal/casino/registry.go | 18 |
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) }, |
