From e4400c5f1e84c18d2126f2cb502ae10685977cbb Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Sat, 20 Jun 2026 03:20:01 -0400 Subject: refactor: combined all station crafting --- internal/game/core_startup.go | 65 +++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 27 deletions(-) (limited to 'internal/game/core_startup.go') diff --git a/internal/game/core_startup.go b/internal/game/core_startup.go index ab52762..ef33ff7 100644 --- a/internal/game/core_startup.go +++ b/internal/game/core_startup.go @@ -8,6 +8,7 @@ import ( "strings" "thehouseoficarus/internal/action" + "thehouseoficarus/internal/world" ) type StartupIssue struct { @@ -19,29 +20,29 @@ type StartupIssue struct { func (g *Game) ValidateStartup() []StartupIssue { var issues []StartupIssue - issues = append(issues, validateDuplicateIDs(g.DataDir, "items", "item")...) - issues = append(issues, validateDuplicateIDs(g.DataDir, "rooms", "room")...) - issues = append(issues, validateDuplicateIDs(g.DataDir, "mobs", "mob")...) - issues = append(issues, validateDuplicateIDs(g.DataDir, "objects", "object")...) - issues = append(issues, validateDuplicateIDs(g.DataDir, "drops", "drop table")...) - issues = append(issues, validateDuplicateIDs(g.DataDir, "recipes", "recipe")...) - issues = append(issues, validateDuplicateIDs(g.DataDir, "courses", "course")...) - issues = append(issues, validateDuplicateIDs(g.DataDir, "modules", "module")...) - issues = append(issues, validateDuplicateIDs(g.DataDir, "help", "help topic")...) - - issues = append(issues, validateRoomReferences(g)...) - issues = append(issues, validateMobReferences(g)...) - issues = append(issues, validateObjectReferences(g)...) - issues = append(issues, validateItemReferences(g)...) - issues = append(issues, validateRecipeReferences(g)...) - issues = append(issues, validateDropTableReferences(g)...) - issues = append(issues, validateCourseReferences(g)...) + issues = append(issues, validateIDs(g.DataDir, "items", "item")...) + issues = append(issues, validateIDs(g.DataDir, "rooms", "room")...) + issues = append(issues, validateIDs(g.DataDir, "mobs", "mob")...) + issues = append(issues, validateIDs(g.DataDir, "objects", "object")...) + issues = append(issues, validateIDs(g.DataDir, "drops", "drop table")...) + issues = append(issues, validateIDs(g.DataDir, "recipes", "recipe")...) + issues = append(issues, validateIDs(g.DataDir, "courses", "course")...) + issues = append(issues, validateIDs(g.DataDir, "modules", "module")...) + issues = append(issues, validateIDs(g.DataDir, "help", "help topic")...) + + issues = append(issues, validateRooms(g)...) + issues = append(issues, validateMobs(g)...) + issues = append(issues, validateObjects(g)...) + issues = append(issues, validateItems(g)...) + issues = append(issues, validateRecipes(g)...) + issues = append(issues, validateDropTables(g)...) + issues = append(issues, validateCourses(g)...) issues = append(issues, validateRoomWiring(g)...) return issues } -func validateDuplicateIDs(dataDir, subDir, label string) []StartupIssue { +func validateIDs(dataDir, subDir, label string) []StartupIssue { dir := filepath.Join(dataDir, subDir) dups := action.CheckDuplicateIDs(dir) var issues []StartupIssue @@ -60,7 +61,7 @@ func validateDuplicateIDs(dataDir, subDir, label string) []StartupIssue { return issues } -func validateRoomReferences(g *Game) []StartupIssue { +func validateRooms(g *Game) []StartupIssue { var issues []StartupIssue roomIndex := g.World.RoomIndex() itemIDs := g.ItemStore.IDSet() @@ -86,6 +87,16 @@ func validateRoomReferences(g *Game) []StartupIssue { } for dir, exit := range room.Exits { + switch dir { + case world.North, world.South, world.East, world.West, world.Up, world.Down: + default: + issues = append(issues, StartupIssue{ + Level: "ERROR", + Type: "reference", + Message: fmt.Sprintf("Room %d: invalid exit direction %q (only north/south/east/west/up/down supported)", id, dir), + }) + continue + } if exit.Room <= 0 { continue } @@ -159,7 +170,7 @@ func validateRoomReferences(g *Game) []StartupIssue { return issues } -func validateMobReferences(g *Game) []StartupIssue { +func validateMobs(g *Game) []StartupIssue { var issues []StartupIssue itemIDs := g.ItemStore.IDSet() dropIDs := dropTableIDSet(g.DataDir) @@ -233,7 +244,7 @@ func validateMobReferences(g *Game) []StartupIssue { return issues } -func validateObjectReferences(g *Game) []StartupIssue { +func validateObjects(g *Game) []StartupIssue { var issues []StartupIssue objIDs := g.ObjectStore.IDSet() itemIDs := g.ItemStore.IDSet() @@ -301,7 +312,7 @@ func validateObjectReferences(g *Game) []StartupIssue { } if obj.Gather != nil { - issues = append(issues, validateGatherConfig(fmt.Sprintf("Object %q: gather", id), obj.Gather, itemIDs, dropIDs)...) + issues = append(issues, validateGather(fmt.Sprintf("Object %q: gather", id), obj.Gather, itemIDs, dropIDs)...) } if obj.Talk != nil { @@ -316,7 +327,7 @@ func validateObjectReferences(g *Game) []StartupIssue { return issues } -func validateItemReferences(g *Game) []StartupIssue { +func validateItems(g *Game) []StartupIssue { var issues []StartupIssue itemIDs := g.ItemStore.IDSet() dropIDs := dropTableIDSet(g.DataDir) @@ -393,7 +404,7 @@ func validateItemReferences(g *Game) []StartupIssue { return issues } -func validateRecipeReferences(g *Game) []StartupIssue { +func validateRecipes(g *Game) []StartupIssue { var issues []StartupIssue itemIDs := g.ItemStore.IDSet() @@ -456,7 +467,7 @@ func validateRecipeReferences(g *Game) []StartupIssue { return issues } -func validateDropTableReferences(g *Game) []StartupIssue { +func validateDropTables(g *Game) []StartupIssue { var issues []StartupIssue dropIDs := dropTableIDSet(g.DataDir) itemIDs := g.ItemStore.IDSet() @@ -494,7 +505,7 @@ func validateDropTableReferences(g *Game) []StartupIssue { return issues } -func validateCourseReferences(g *Game) []StartupIssue { +func validateCourses(g *Game) []StartupIssue { var issues []StartupIssue roomIndex := g.World.RoomIndex() @@ -582,7 +593,7 @@ func validateRoomWiring(g *Game) []StartupIssue { return issues } -func validateGatherConfig(prefix string, cfg *action.GatherConfig, itemIDs map[string]bool, dropIDs map[string]bool) []StartupIssue { +func validateGather(prefix string, cfg *action.GatherConfig, itemIDs map[string]bool, dropIDs map[string]bool) []StartupIssue { var issues []StartupIssue if cfg.Bait != "" && !itemIDs[cfg.Bait] { -- cgit v1.2.3