aboutsummaryrefslogtreecommitdiff
path: root/internal/validate/checks.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-25 20:33:47 -0400
committerhistoria <[not public]>2026-06-25 20:33:47 -0400
commit84d74ca4351a97148ad8339676f9df7946bc21fb (patch)
treea9f50ac56e8bbcdf2b307ef6f7143b67bce46c61 /internal/validate/checks.go
parentc55d0e4150b23f2c5c9f96bbc3d4dc2fc6dbaa36 (diff)
downloadthehouseoficarus-84d74ca4351a97148ad8339676f9df7946bc21fb.tar.gz
feat: trigger system for scripted events added.
Diffstat (limited to 'internal/validate/checks.go')
-rw-r--r--internal/validate/checks.go68
1 files changed, 68 insertions, 0 deletions
diff --git a/internal/validate/checks.go b/internal/validate/checks.go
index 6aa0a81..197b8d3 100644
--- a/internal/validate/checks.go
+++ b/internal/validate/checks.go
@@ -521,6 +521,74 @@ func validateCourses(s Source) []Issue {
return issues
}
+func validateRoomTriggers(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.Triggers) == 0 {
+ continue
+ }
+ for ti, trigger := range room.Triggers {
+ prefix := fmt.Sprintf("Room %d: trigger[%d]", id, ti)
+ for si, step := range trigger.Steps {
+ stepPrefix := fmt.Sprintf("%s: step[%d]", prefix, 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 validateRoomWiring(s Source) []Issue {
var issues []Issue
roomIndex := s.World.RoomIndex()