diff options
| author | historia <[not public]> | 2026-07-10 20:37:29 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-07-10 20:37:29 -0400 |
| commit | 131cbbe586463a7232f332650af5f0b2c13dc7e9 (patch) | |
| tree | 080ac50225b2ec07c01dbca22e4480fb8046a156 /internal/validate/checks.go | |
| parent | d35aa505d2a103a41a45d3a8f42be7f2f2b5a28b (diff) | |
| download | thehouseoficarus-131cbbe586463a7232f332650af5f0b2c13dc7e9.tar.gz | |
feat(admin): remove unused fields from drop tables
Diffstat (limited to 'internal/validate/checks.go')
| -rw-r--r-- | internal/validate/checks.go | 72 |
1 files changed, 71 insertions, 1 deletions
diff --git a/internal/validate/checks.go b/internal/validate/checks.go index f89e52d..bbcb820 100644 --- a/internal/validate/checks.go +++ b/internal/validate/checks.go @@ -2,6 +2,8 @@ package validate import ( "fmt" + "os" + "path/filepath" "sort" "strings" @@ -732,7 +734,24 @@ func validateDropTables(s Source) []Issue { }) continue } - for _, d := range dt.Drops { + + // Detect files that use "entries:" instead of "drops:" as the top-level list key. + // DropTableDef only reads "drops:", so "entries:" produces an empty list. + if len(dt.Drops) == 0 { + raw, rawErr := os.ReadFile(filepath.Join(s.DataDir, "drops", id+".yaml")) + if rawErr == nil { + content := string(raw) + if strings.Contains(content, "\nentries:") || strings.HasPrefix(content, "entries:") { + issues = append(issues, Issue{ + Level: "ERROR", + Type: "integrity", + Message: fmt.Sprintf("Drop table %q: uses key 'entries:' instead of 'drops:' — entries are not loaded; rename to 'drops:'", id), + }) + } + } + } + + for i, d := range dt.Drops { if d.ItemID != "" && !itemIDs[d.ItemID] { issues = append(issues, Issue{ Level: "ERROR", @@ -749,6 +768,57 @@ func validateDropTables(s Source) []Issue { id, d.Table), }) } + + if d.ItemID != "" && d.Table != "" { + issues = append(issues, Issue{ + Level: "WARN", + Type: "integrity", + Message: fmt.Sprintf("Drop table %q entry %d: both item_id and table set (only one is used per entry)", id, i+1), + }) + } + if d.ItemID == "" && d.Table == "" { + issues = append(issues, Issue{ + Level: "WARN", + Type: "integrity", + Message: fmt.Sprintf("Drop table %q entry %d: neither item_id nor table set (roll produces nothing)", id, i+1), + }) + } + + if d.Depletes { + issues = append(issues, Issue{ + Level: "WARN", + Type: "integrity", + Message: fmt.Sprintf("Drop table %q entry %d: 'depletes' is ignored on shared drop table entries; set it on the gather entry that references this table instead", id, i+1), + }) + } + if d.Level > 0 { + issues = append(issues, Issue{ + Level: "WARN", + Type: "integrity", + Message: fmt.Sprintf("Drop table %q entry %d: 'level' is ignored on shared drop table entries; set it on the gather entry that references this table", id, i+1), + }) + } + if d.XP > 0 { + issues = append(issues, Issue{ + Level: "WARN", + Type: "integrity", + Message: fmt.Sprintf("Drop table %q entry %d: 'xp' is ignored on shared drop table entries; set it on the gather entry that references this table", id, i+1), + }) + } + if d.Tool != "" { + issues = append(issues, Issue{ + Level: "WARN", + Type: "integrity", + Message: fmt.Sprintf("Drop table %q entry %d: 'tool' is ignored on shared drop table entries; set it on the gather entry that references this table", id, i+1), + }) + } + if d.SuccessMessage != "" { + issues = append(issues, Issue{ + Level: "WARN", + Type: "integrity", + Message: fmt.Sprintf("Drop table %q entry %d: 'success_message' is ignored on shared drop table entries; set it on the gather entry that references this table", id, i+1), + }) + } } } |
