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/validate | |
| parent | b3568f03e4103dd46db2ccc680fbab0a6454d604 (diff) | |
| download | thehouseoficarus-396c3facb8287b9a34076cae8f3d7b300d366d99.tar.gz | |
fix: atomic saves, casino RNG/config isolation, tick lifecycle
Diffstat (limited to 'internal/validate')
| -rw-r--r-- | internal/validate/casino_test.go | 29 | ||||
| -rw-r--r-- | internal/validate/checks.go | 7 |
2 files changed, 36 insertions, 0 deletions
diff --git a/internal/validate/casino_test.go b/internal/validate/casino_test.go new file mode 100644 index 0000000..9eb94db --- /dev/null +++ b/internal/validate/casino_test.go @@ -0,0 +1,29 @@ +package validate + +import ( + "path/filepath" + "testing" +) + +func TestRoomCasinoValidation(t *testing.T) { + dir := t.TempDir() + writeFile(t, filepath.Join(dir, "rooms", "1.yaml"), `name: Casino +casino_tables: + - id: cards + game: blackjack + min_bet: 10 + max_bet: 5 +casino_machines: + - id: slots + game: slots + payout: .nan + - id: slots + game: slots +`) + issues := validateRooms(newSource(dir)) + for _, message := range []string{"Room 1", "max_bet", "payout", "duplicate casino id"} { + if !containsMsg(issues, message) { + t.Errorf("missing %q in %+v", message, issues) + } + } +} diff --git a/internal/validate/checks.go b/internal/validate/checks.go index 527b558..344df3a 100644 --- a/internal/validate/checks.go +++ b/internal/validate/checks.go @@ -8,6 +8,7 @@ import ( "strings" "thehouseoficarus/internal/behavior" + "thehouseoficarus/internal/casino" "thehouseoficarus/internal/color" "thehouseoficarus/internal/combat" "thehouseoficarus/internal/world" @@ -31,6 +32,12 @@ func validateRooms(s Source) []Issue { }) continue } + if err := casino.ValidateRoomConfigs(room.CasinoTables, room.CasinoMachines); err != nil { + issues = append(issues, Issue{ + Level: "ERROR", Type: "casino", + Message: fmt.Sprintf("Room %d: %v", id, err), + }) + } if room.Name == "" { issues = append(issues, Issue{ Level: "WARN", |
