aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2014-04-19 14:55:34 +0200
committerPacien TRAN-GIRARD2014-04-19 14:55:34 +0200
commitb0709c8a9de47169bbee25eed895d06fbeead12a (patch)
treec3ff2a4be7bd1847cfd25f15c5244ac78001f6da /src
parent86d6f56dd14fdb94411a02679b9ad4bd556d8a32 (diff)
downloadesieequest-b0709c8a9de47169bbee25eed895d06fbeead12a.tar.gz
Move the challenge mode logic
Diffstat (limited to 'src')
-rw-r--r--src/esieequest/controller/commands/GoCommand.java3
-rw-r--r--src/esieequest/model/Player.java10
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}