aboutsummaryrefslogtreecommitdiff
path: root/internal/validate
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-25 19:37:20 -0400
committerhistoria <[not public]>2026-06-25 19:37:20 -0400
commitc55d0e4150b23f2c5c9f96bbc3d4dc2fc6dbaa36 (patch)
treed1c02acea2b4c8d0f672c1539cfdb373b6272ed0 /internal/validate
parent068ce514ea3eebdc42b595c631b4b00ce4594577 (diff)
downloadthehouseoficarus-c55d0e4150b23f2c5c9f96bbc3d4dc2fc6dbaa36.tar.gz
feat: yaml conversation trees more robust
Diffstat (limited to 'internal/validate')
-rw-r--r--internal/validate/checks.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/internal/validate/checks.go b/internal/validate/checks.go
index bb7cbd9..6aa0a81 100644
--- a/internal/validate/checks.go
+++ b/internal/validate/checks.go
@@ -152,6 +152,14 @@ func validateMobs(s Source) []Issue {
})
}
+ if !def.Protected && def.HP <= 0 {
+ issues = append(issues, Issue{
+ Level: "ERROR",
+ Type: "reference",
+ Message: fmt.Sprintf("Mob %q: is not protected but has HP=%d — mobs must have hp > 0 (or set protected: true)", id, def.HP),
+ })
+ }
+
if def.Kind != "" && def.Kind != "combat" && def.Kind != "task" {
issues = append(issues, Issue{
Level: "ERROR",
@@ -322,6 +330,10 @@ func validateObjects(s Source) []Issue {
if obj.Use != nil {
issues = append(issues, validateUseConfig(fmt.Sprintf("Object %q: use", id), obj.Use, itemIDs)...)
}
+
+ if obj.OnLook != nil {
+ issues = append(issues, validateNodeAction(fmt.Sprintf("Object %q: on_look", id), obj.OnLook, itemIDs, roomIndex)...)
+ }
}
return issues
@@ -666,6 +678,21 @@ func validateTalkConfig(prefix string, cfg *behavior.TalkConfig, itemIDs map[str
if node.Action != nil {
issues = append(issues, validateNodeAction(nodePrefix, node.Action, itemIDs, roomIndex)...)
}
+ if node.Next != "" {
+ if _, ok := cfg.Nodes[node.Next]; !ok {
+ issues = append(issues, Issue{
+ Level: "ERROR",
+ Type: "reference",
+ Message: fmt.Sprintf("%s: next points to nonexistent node %q", nodePrefix, node.Next),
+ })
+ }
+ }
+ for i, opt := range node.Options {
+ optPrefix := fmt.Sprintf("%s: option %d", nodePrefix, i+1)
+ if opt.Action != nil {
+ issues = append(issues, validateNodeAction(optPrefix, opt.Action, itemIDs, roomIndex)...)
+ }
+ }
}
return issues
}