diff options
| author | historia <[not public]> | 2026-06-25 21:23:34 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-25 21:23:34 -0400 |
| commit | e2d5b081f27141bb3dd89dbe595860b8a1345d55 (patch) | |
| tree | 3090f8150580fe85a872caa04165ff70613bbaa8 /internal/validate | |
| parent | 84d74ca4351a97148ad8339676f9df7946bc21fb (diff) | |
| download | thehouseoficarus-e2d5b081f27141bb3dd89dbe595860b8a1345d55.tar.gz | |
feat: on_enter features ported over to triggers, cosmetic fixes with trigger messages
Diffstat (limited to 'internal/validate')
| -rw-r--r-- | internal/validate/checks.go | 60 | ||||
| -rw-r--r-- | internal/validate/validate.go | 1 |
2 files changed, 61 insertions, 0 deletions
diff --git a/internal/validate/checks.go b/internal/validate/checks.go index 197b8d3..9cff717 100644 --- a/internal/validate/checks.go +++ b/internal/validate/checks.go @@ -521,6 +521,66 @@ func validateCourses(s Source) []Issue { return issues } +func validateRoomEnterSteps(s Source) []Issue { + var issues []Issue + roomIndex := s.World.RoomIndex() + itemIDs := s.Items.IDSet() + mobIDs := s.Mobs.AllDefIDs() + + for id := range roomIndex { + room, err := s.World.LoadRoom(id) + if err != nil || len(room.OnEnter) == 0 { + continue + } + for si, step := range room.OnEnter { + stepPrefix := fmt.Sprintf("Room %d: on_enter[%d]", id, si) + if step.SpawnMob != nil && step.SpawnMob.ID != "" { + if _, ok := mobIDs[step.SpawnMob.ID]; !ok { + issues = append(issues, Issue{ + Level: "ERROR", + Type: "reference", + Message: fmt.Sprintf("%s: spawn_mob %q does not exist", stepPrefix, step.SpawnMob.ID), + }) + } + for _, wr := range step.SpawnMob.DespawnRooms { + if _, ok := roomIndex[wr]; !ok { + issues = append(issues, Issue{ + Level: "ERROR", + Type: "reference", + Message: fmt.Sprintf("%s: spawn_mob despawn_rooms references nonexistent room %d", stepPrefix, wr), + }) + } + } + } + if step.GiveItem != "" && !itemIDs[step.GiveItem] { + issues = append(issues, Issue{ + Level: "ERROR", + Type: "reference", + Message: fmt.Sprintf("%s: give_item %q does not exist", stepPrefix, step.GiveItem), + }) + } + if step.TakeItem != "" && !itemIDs[step.TakeItem] { + issues = append(issues, Issue{ + Level: "ERROR", + Type: "reference", + Message: fmt.Sprintf("%s: take_item %q does not exist", stepPrefix, step.TakeItem), + }) + } + if step.Teleport > 0 { + if _, ok := roomIndex[step.Teleport]; !ok { + issues = append(issues, Issue{ + Level: "ERROR", + Type: "reference", + Message: fmt.Sprintf("%s: teleport to nonexistent room %d", stepPrefix, step.Teleport), + }) + } + } + } + } + + return issues +} + func validateRoomTriggers(s Source) []Issue { var issues []Issue roomIndex := s.World.RoomIndex() diff --git a/internal/validate/validate.go b/internal/validate/validate.go index 3918c95..36969ed 100644 --- a/internal/validate/validate.go +++ b/internal/validate/validate.go @@ -77,6 +77,7 @@ func Run(s Source) []Issue { issues = append(issues, validateDropTables(s)...) issues = append(issues, validateCourses(s)...) issues = append(issues, validateRoomTriggers(s)...) + issues = append(issues, validateRoomEnterSteps(s)...) issues = append(issues, validateTechs(s)...) issues = append(issues, validateRoomWiring(s)...) |
