From c55d0e4150b23f2c5c9f96bbc3d4dc2fc6dbaa36 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Thu, 25 Jun 2026 19:37:20 -0400 Subject: feat: yaml conversation trees more robust --- internal/validate/checks.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'internal/validate') 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 } -- cgit v1.2.3