diff options
| author | historia <[not public]> | 2026-09-15 14:18:14 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-15 14:18:14 -0400 |
| commit | 396c3facb8287b9a34076cae8f3d7b300d366d99 (patch) | |
| tree | 941f280d051fac474fa68ca08318a8d16adc8d0f /internal/admin/casino_validate.go | |
| parent | b3568f03e4103dd46db2ccc680fbab0a6454d604 (diff) | |
| download | thehouseoficarus-396c3facb8287b9a34076cae8f3d7b300d366d99.tar.gz | |
fix: atomic saves, casino RNG/config isolation, tick lifecycle
Diffstat (limited to 'internal/admin/casino_validate.go')
| -rw-r--r-- | internal/admin/casino_validate.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/internal/admin/casino_validate.go b/internal/admin/casino_validate.go new file mode 100644 index 0000000..5b6902c --- /dev/null +++ b/internal/admin/casino_validate.go @@ -0,0 +1,33 @@ +package admin + +import ( + "bytes" + + "gopkg.in/yaml.v3" + "thehouseoficarus/internal/casino" +) + +// Validate before any room/link writes. Only casino fields are decoded here; +// the room editor's unrelated fields retain their existing representation. +func validateRoomCasinoMap(m map[string]any) error { + fields := map[string]any{} + for _, key := range []string{"casino_tables", "casino_machines"} { + if value, ok := m[key]; ok { + fields[key] = value + } + } + data, err := yaml.Marshal(fields) + if err != nil { + return err + } + var cfg struct { + Tables []casino.TableConfig `yaml:"casino_tables"` + Machines []casino.MachineConfig `yaml:"casino_machines"` + } + decoder := yaml.NewDecoder(bytes.NewReader(data)) + decoder.KnownFields(true) + if err := decoder.Decode(&cfg); err != nil { + return err + } + return casino.ValidateRoomConfigs(cfg.Tables, cfg.Machines) +} |
