diff options
Diffstat (limited to 'internal/validate/checks.go')
| -rw-r--r-- | internal/validate/checks.go | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/internal/validate/checks.go b/internal/validate/checks.go index b35a3de..cdeee44 100644 --- a/internal/validate/checks.go +++ b/internal/validate/checks.go @@ -377,6 +377,44 @@ func validateMobs(s Source) []Issue { id, def.FinishingBlow), }) } + + if def.Shop != nil { + if def.Shop.BuyPercentage < 0 || def.Shop.ChangePercentage < 0 { + issues = append(issues, Issue{ + Level: "ERROR", + Type: "reference", + Message: fmt.Sprintf("Mob %q: shop buy_percentage/change_percentage must not be negative", id), + }) + } + seenShop := map[string]bool{} + for _, si := range def.Shop.Items { + if si.ItemID == "" { + continue + } + if !itemIDs[si.ItemID] { + issues = append(issues, Issue{ + Level: "ERROR", + Type: "reference", + Message: fmt.Sprintf("Mob %q: shop item %q does not exist", id, si.ItemID), + }) + } + if seenShop[si.ItemID] { + issues = append(issues, Issue{ + Level: "WARN", + Type: "reference", + Message: fmt.Sprintf("Mob %q: shop lists item %q more than once", id, si.ItemID), + }) + } + seenShop[si.ItemID] = true + if si.Stock < 0 { + issues = append(issues, Issue{ + Level: "ERROR", + Type: "reference", + Message: fmt.Sprintf("Mob %q: shop item %q has negative stock", id, si.ItemID), + }) + } + } + } } return issues @@ -865,7 +903,6 @@ func validateRoomWiring(s Source) []Issue { return issues } - // validateRoomGrid embeds the entire reachable world on a single 3D grid // starting from the configured root rooms and reports when the exit layout // cannot be embedded without conflict: @@ -1170,18 +1207,5 @@ func validateNodeAction(prefix string, na *behavior.NodeAction, itemIDs map[stri } } - if na.Shop != nil { - for _, si := range na.Shop.Items { - if si.ItemID != "" && !itemIDs[si.ItemID] { - issues = append(issues, Issue{ - Level: "ERROR", - Type: "reference", - Message: fmt.Sprintf("%s: shop item %q does not exist", - prefix, si.ItemID), - }) - } - } - } - return issues } |
