Enforce durable enemy event validation

This commit is contained in:
2026-08-09 02:03:27 +00:00
parent b3644abc0e
commit 82ffe85f2d
12 changed files with 313 additions and 28 deletions

View File

@@ -8,6 +8,7 @@ import (
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/codec/candidatejson"
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/codec/sourcerange"
)
const (
@@ -91,11 +92,8 @@ func validate(value dnd.SpellList) error {
if strings.TrimSpace(ref.SourceID) == "" {
return fmt.Errorf("spell_casts[%d].source_refs[%d].source_id must not be empty", index, refIndex)
}
if ref.StartUnitID <= 0 {
return fmt.Errorf("spell_casts[%d].source_refs[%d].start_unit_id must be positive", index, refIndex)
}
if ref.EndUnitID <= 0 {
return fmt.Errorf("spell_casts[%d].source_refs[%d].end_unit_id must be positive", index, refIndex)
if err := sourcerange.Validate(ref); err != nil {
return fmt.Errorf("spell_casts[%d].source_refs[%d]: %w", index, refIndex, err)
}
}
}