diff options
Diffstat (limited to 'internal/validate/checks.go')
| -rw-r--r-- | internal/validate/checks.go | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/internal/validate/checks.go b/internal/validate/checks.go index 360f97c..7cb5914 100644 --- a/internal/validate/checks.go +++ b/internal/validate/checks.go @@ -1113,14 +1113,6 @@ func validateTechs(s Source) []Issue { func validateGather(prefix string, cfg *behavior.GatherConfig, itemIDs map[string]bool, dropIDs map[string]bool) []Issue { var issues []Issue - if len(cfg.Tools) == 0 { - issues = append(issues, Issue{ - Level: "ERROR", - Type: "config", - Message: fmt.Sprintf("%s: gather must have at least one tool", prefix), - }) - } - if cfg.Bait != "" && !itemIDs[cfg.Bait] { issues = append(issues, Issue{ Level: "ERROR", @@ -1147,11 +1139,41 @@ func validateGather(prefix string, cfg *behavior.GatherConfig, itemIDs map[strin prefix, d.Table), }) } + if d.Tool != "" { + if !toolInList(cfg.Tools, d.Tool) { + issues = append(issues, Issue{ + Level: "ERROR", + Type: "reference", + Message: fmt.Sprintf("%s: drop tool %q is not in the object's tools list", + prefix, d.Tool), + }) + } + } else if len(cfg.Tools) >= 2 { + label := d.ItemID + if label == "" { + label = "<table:" + d.Table + ">" + } + issues = append(issues, Issue{ + Level: "ERROR", + Type: "config", + Message: fmt.Sprintf("%s: drop %q has no tool; required because object has %d tools", + prefix, label, len(cfg.Tools)), + }) + } } return issues } +func toolInList(list []string, target string) bool { + for _, t := range list { + if t == target { + return true + } + } + return false +} + func validateTalkConfig(prefix string, cfg *behavior.TalkConfig, itemIDs map[string]bool, roomIndex map[int]bool) []Issue { var issues []Issue if cfg == nil { |
