From c705ae942573984784ef501bf8198f61f5206ddd Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Thu, 9 Jul 2026 05:27:10 -0400 Subject: refactor: simplify yaml, remove support for old scalar fields --- internal/game/core_course_test.go | 45 +++++++++++---------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) (limited to 'internal/game/core_course_test.go') diff --git a/internal/game/core_course_test.go b/internal/game/core_course_test.go index 64ec8ad..93f49f5 100644 --- a/internal/game/core_course_test.go +++ b/internal/game/core_course_test.go @@ -6,7 +6,7 @@ import ( "testing" ) -func TestResolvePhasesPrefersExplicitPhases(t *testing.T) { +func TestResolvePhases(t *testing.T) { obs := ObstacleDef{ RoomID: 5, Verb: "climb", @@ -15,9 +15,6 @@ func TestResolvePhasesPrefersExplicitPhases(t *testing.T) { {Message: "middle", Delay: 2, FailCheck: true}, {Message: "end", Delay: 1.5}, }, - // Legacy fields set as a decoy; should be ignored when Phases present. - TicksPerPhase: 99, - Messages: []string{"ignored1", "ignored2", "ignored3"}, } got := resolvePhases(obs) if len(got) != 3 { @@ -34,28 +31,6 @@ func TestResolvePhasesPrefersExplicitPhases(t *testing.T) { } } -func TestResolvePhasesLegacyMigration(t *testing.T) { - obs := ObstacleDef{ - RoomID: 7, - Verb: "jump", - TicksPerPhase: 2, - Messages: []string{"a", "b", "c"}, - } - got := resolvePhases(obs) - if len(got) != 3 { - t.Fatalf("expected 3 legacy phases, got %d", len(got)) - } - if got[0].Message != "a" || got[0].Delay != 0 || got[0].FailCheck { - t.Errorf("legacy phase 0 wrong: %+v", got[0]) - } - if got[1].Message != "b" || got[1].Delay != 2 || !got[1].FailCheck { - t.Errorf("legacy phase 1 must carry fail_check at index 1: %+v", got[1]) - } - if got[2].Message != "c" || got[2].Delay != 2 || got[2].FailCheck { - t.Errorf("legacy phase 2 wrong: %+v", got[2]) - } -} - func TestCourseStoreLoadsWithExplicitFailChance(t *testing.T) { dir := t.TempDir() coursesDir := filepath.Join(dir, "courses") @@ -85,8 +60,14 @@ obstacles: verb: jump xp: 14 fail_damage: [1, 3] - messages: ["p0", "p1", "p2"] - ticks_per_phase: 1 + phases: + - message: "p0" + delay: 0 + - message: "p1" + delay: 1 + fail_check: true + - message: "p2" + delay: 1 `) if err := os.WriteFile(filepath.Join(coursesDir, "testcourse.yaml"), yaml, 0644); err != nil { t.Fatal(err) @@ -116,16 +97,16 @@ obstacles: t.Errorf("first obstacle should have no completion xp, got %d", o1.CompletionXP) } - // Obstacle 2: legacy migration, derived fail chance (nil) + // Obstacle 2: explicit phases, derived fail chance (nil) o2 := cs.GetObstacle(102) if o2 == nil { t.Fatal("expected obstacle for room 102") } if len(o2.Phases) != 3 || !o2.Phases[1].FailCheck { - t.Errorf("legacy obstacle phases not migrated: %+v", o2.Phases) + t.Errorf("obstacle 2 phases wrong: %+v", o2.Phases) } if o2.FailChance != nil { - t.Errorf("legacy obstacle should have nil (derived) fail_chance, got %v", *o2.FailChance) + t.Errorf("obstacle 2 should have nil (derived) fail_chance, got %v", *o2.FailChance) } if o2.CompletionXP != 50 { t.Errorf("last obstacle should carry completion_xp, got %d", o2.CompletionXP) @@ -137,4 +118,4 @@ obstacles: if cs.GetObstacle(999) != nil { t.Error("expected nil for unrelated room") } -} \ No newline at end of file +} -- cgit v1.2.3