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:
@@ -22,6 +22,7 @@ public final class TutorialGuide {
|
||||
private final CommandRegistry registry;
|
||||
private int index;
|
||||
private boolean active;
|
||||
private boolean begun;
|
||||
private Room roomAtStepStart;
|
||||
|
||||
public TutorialGuide(Tutorial tutorial, CommandRegistry registry) {
|
||||
@@ -30,15 +31,17 @@ public final class TutorialGuide {
|
||||
this.active = !tutorial.isEmpty();
|
||||
}
|
||||
|
||||
/** @return true while the walkthrough is still running. */
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
/** Prints the intro and the first instruction (call once at loop start). */
|
||||
public void begin(GameContext ctx) {
|
||||
if (!active) {
|
||||
if (!active || begun) {
|
||||
return;
|
||||
}
|
||||
begun = true;
|
||||
if (tutorial.intro() != null && !tutorial.intro().isBlank()) {
|
||||
ctx.getIo().write(tutorial.intro());
|
||||
}
|
||||
@@ -108,7 +111,8 @@ public final class TutorialGuide {
|
||||
}
|
||||
|
||||
private boolean moved(GameContext ctx) {
|
||||
return ctx.getPlayer().getCurrentRoom() != roomAtStepStart;
|
||||
return roomAtStepStart != null
|
||||
&& ctx.getPlayer().getCurrentRoom() != roomAtStepStart;
|
||||
}
|
||||
|
||||
private boolean sameCommand(String a, String b) {
|
||||
|
||||
Reference in New Issue
Block a user