diff options
-rw-r--r-- | src/esieequest/controller/commands/GoCommand.java | 3 | ||||
-rw-r--r-- | src/esieequest/model/Player.java | 10 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/esieequest/controller/commands/GoCommand.java b/src/esieequest/controller/commands/GoCommand.java index 06260b2..61718a1 100644 --- a/src/esieequest/controller/commands/GoCommand.java +++ b/src/esieequest/controller/commands/GoCommand.java | |||
@@ -42,8 +42,7 @@ public class GoCommand implements CommandInterface { | |||
42 | view.updateRoom(game.getPlayer().getCurrentRoom()); | 42 | view.updateRoom(game.getPlayer().getCurrentRoom()); |
43 | 43 | ||
44 | // handle challenge mode | 44 | // handle challenge mode |
45 | game.getPlayer().setNbSteps(game.getPlayer().getNbSteps() + 1); | 45 | if (game.getPlayer().walk()) { |
46 | if (game.getPlayer().getNbSteps() == game.getPlayer().getNbStepsLimit()) { | ||
47 | view.echo(Text.CHALLENGE_FAILED.getText()); | 46 | view.echo(Text.CHALLENGE_FAILED.getText()); |
48 | view.disable(); | 47 | view.disable(); |
49 | } | 48 | } |
diff --git a/src/esieequest/model/Player.java b/src/esieequest/model/Player.java index a35a776..3851c44 100644 --- a/src/esieequest/model/Player.java +++ b/src/esieequest/model/Player.java | |||
@@ -285,4 +285,14 @@ public class Player { | |||
285 | return item; | 285 | return item; |
286 | } | 286 | } |
287 | 287 | ||
288 | /** | ||
289 | * Increments the step counter. | ||
290 | * | ||
291 | * @return if the maximum number of steps has been reached | ||
292 | */ | ||
293 | public boolean walk() { | ||
294 | this.nbSteps++; | ||
295 | return this.nbSteps == this.nbStepsLimit; | ||
296 | } | ||
297 | |||
288 | } | 298 | } |