fix(game): null-safe moved() + idempotent begin(); cover multi-step + go_to_room hint

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-01 21:49:47 +02:00
parent 546a7672bf
commit 28871b4ddc
2 changed files with 29 additions and 2 deletions

View File

@@ -140,4 +140,27 @@ class TutorialGuideTest {
TutorialGuide g = new TutorialGuide(Tutorial.none(), registry());
assertThat(g.isActive()).isFalse();
}
@Test
void advancingPrintsTheNextInstruction() {
GameContext ctx = ctx();
Tutorial t = new Tutorial("I",
List.of(step("do look", "look", 0), step("do take", "take", 1)), "TIPS");
TutorialGuide g = new TutorialGuide(t, registry());
g.begin(ctx);
g.onCommand(ctx, parse("look"));
assertThat(out(ctx)).contains("OK:look").contains("do take");
assertThat(g.isActive()).isTrue();
}
@Test
void goToRoomWithoutMovingGivesHint() {
GameContext ctx = ctx();
Tutorial t = new Tutorial("I", List.of(step("travel", "go_to_room", 0)), "TIPS");
TutorialGuide g = new TutorialGuide(t, registry());
g.begin(ctx);
g.onCommand(ctx, parse("go kitchen")); // non-direction arg but no room change
assertThat(out(ctx)).contains("HINT:go_to_room");
assertThat(g.isActive()).isTrue();
}
}