package game // Shared helpers for the crafting/combat hardening regressions. The tests // build a real Game (owner loop, stores, craft index) over a temp data dir // but deliberately do NOT start a background ticker, so each test drives // production/combat cycles with explicit calls and asserts without racing // Game.AdvanceActions. import ( "os" "path/filepath" "testing" "thehouseoficarus/internal/config" "thehouseoficarus/internal/net" ) // newHardeningGame builds a real Game over dir with an owner loop but no // background ticker. stopOwner is registered for cleanup so the owner // goroutine does not leak. func newHardeningGame(t *testing.T, dir string) *Game { t.Helper() colors := &config.ColorsConfig{} g := New(dir, colors, colors, config.ValidationConfig{}, 1) g.SetHub(net.NewHub()) t.Cleanup(g.stopOwner) return g } // writeDataFile writes subdir/name under dir, creating parent directories. func writeDataFile(t *testing.T, dir, subdir, name, content string) { t.Helper() path := filepath.Join(dir, subdir, name) if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil { t.Fatalf("mkdir %s: %v", subdir, err) } if err := os.WriteFile(path, []byte(content), 0644); err != nil { t.Fatalf("write %s: %v", path, err) } }