aboutsummaryrefslogtreecommitdiff
path: root/internal/validate/checks.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-28 04:30:11 -0400
committerhistoria <[not public]>2026-06-28 04:30:11 -0400
commitfffc132263ab7d3c402992bffbaae4790161f7a7 (patch)
tree91151c29c93517dff15a91fec24f36ee98bc38bf /internal/validate/checks.go
parent82c025b3f3e5cac82800ab9d7f11dcb4e3aa884b (diff)
downloadthehouseoficarus-fffc132263ab7d3c402992bffbaae4790161f7a7.tar.gz
feat: startup validation of opposite-direction exits between rooms
Diffstat (limited to 'internal/validate/checks.go')
-rw-r--r--internal/validate/checks.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/internal/validate/checks.go b/internal/validate/checks.go
index 7da2e4a..87c078e 100644
--- a/internal/validate/checks.go
+++ b/internal/validate/checks.go
@@ -1087,9 +1087,56 @@ func validateTalkConfig(prefix string, cfg *behavior.TalkConfig, itemIDs map[str
}
}
}
+
return issues
}
+func validateExitReciprocity(s Source) []Issue {
+ var issues []Issue
+ roomIndex := s.World.RoomIndex()
+
+ for srcID := range roomIndex {
+ src, err := s.World.LoadRoom(srcID)
+ if err != nil {
+ continue
+ }
+ for dir, exit := range src.Exits {
+ if exit.Room <= 0 || !roomIndex[exit.Room] {
+ continue
+ }
+ if srcID >= exit.Room {
+ continue
+ }
+ dst, err := s.World.LoadRoom(exit.Room)
+ if err != nil {
+ continue
+ }
+ expected := world.OppositeExit[dir]
+ hasCorrect := false
+ var returnDirs []string
+ for retDir, retExit := range dst.Exits {
+ if retExit.Room == srcID {
+ if retDir == expected {
+ hasCorrect = true
+ break
+ }
+ returnDirs = append(returnDirs, string(retDir))
+ }
+ }
+ if !hasCorrect && len(returnDirs) > 0 {
+ issues = append(issues, Issue{
+ Level: "WARN",
+ Type: "integrity",
+ Message: fmt.Sprintf(
+ "Room %d: exit %q to room %d, but return exit(s) %s are not the expected opposite direction %q",
+ srcID, dir, exit.Room, returnDirs, expected),
+ })
+ }
+ }
+ }
+
+ return issues
+}
func validateUseConfig(prefix string, cfg *behavior.UseConfig, itemIDs map[string]bool) []Issue {
var issues []Issue
if cfg == nil {