aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/esieequest/Main.java4
-rw-r--r--src/esieequest/controller/Performer.java10
-rw-r--r--src/esieequest/model/entities/Player.java34
3 files changed, 48 insertions, 0 deletions
diff --git a/src/esieequest/Main.java b/src/esieequest/Main.java
index 59ac568..e8cff08 100755
--- a/src/esieequest/Main.java
+++ b/src/esieequest/Main.java
@@ -62,6 +62,10 @@ public class Main extends JApplet {
62 view = new Window(); 62 view = new Window();
63 } 63 }
64 64
65 if(arguments.contains("--challenge")) {
66 game.getPlayer().setMaxNbSteps(50);
67 }
68
65 new GameEngine(game, view); 69 new GameEngine(game, view);
66 } 70 }
67 71
diff --git a/src/esieequest/controller/Performer.java b/src/esieequest/controller/Performer.java
index 7ba8c94..63cf75b 100644
--- a/src/esieequest/controller/Performer.java
+++ b/src/esieequest/controller/Performer.java
@@ -110,6 +110,7 @@ class Performer {
110 if (nextRoom != null) { 110 if (nextRoom != null) {
111 this.game.getPlayer().goToRoom(nextRoom); 111 this.game.getPlayer().goToRoom(nextRoom);
112 this.view.updateRoom(this.game.getPlayer().getCurrentRoom()); 112 this.view.updateRoom(this.game.getPlayer().getCurrentRoom());
113 this.walk();
113 } else { 114 } else {
114 this.echo(this.game.getNoExitMessage()); 115 this.echo(this.game.getNoExitMessage());
115 } 116 }
@@ -121,6 +122,15 @@ class Performer {
121 public void goBack() { 122 public void goBack() {
122 this.game.getPlayer().goToPreviousRoom(); 123 this.game.getPlayer().goToPreviousRoom();
123 this.view.updateRoom(this.game.getPlayer().getCurrentRoom()); 124 this.view.updateRoom(this.game.getPlayer().getCurrentRoom());
125 this.walk();
126 }
127
128 private void walk() {
129 this.game.getPlayer().setNbSteps(this.game.getPlayer().getNbSteps() + 1);
130 if (this.game.getPlayer().getNbSteps() == this.game.getPlayer().getMaxNbSteps()) {
131 this.echo("You died of exhaustion...");
132 this.quitGame();
133 }
124 } 134 }
125 135
126 /** 136 /**
diff --git a/src/esieequest/model/entities/Player.java b/src/esieequest/model/entities/Player.java
index 91888eb..16ac612 100644
--- a/src/esieequest/model/entities/Player.java
+++ b/src/esieequest/model/entities/Player.java
@@ -12,6 +12,9 @@ public class Player {
12 12
13 private final Inventory inventory; 13 private final Inventory inventory;
14 private final int maxCarryWeight; 14 private final int maxCarryWeight;
15
16 private int nbSteps;
17 private int maxNbSteps;
15 18
16 public Player(final int maxCarryWeight) { 19 public Player(final int maxCarryWeight) {
17 this.currentRoom = null; 20 this.currentRoom = null;
@@ -19,6 +22,9 @@ public class Player {
19 22
20 this.inventory = new Inventory(); 23 this.inventory = new Inventory();
21 this.maxCarryWeight = maxCarryWeight; 24 this.maxCarryWeight = maxCarryWeight;
25
26 this.nbSteps = 0;
27 this.maxNbSteps = 0;
22 } 28 }
23 29
24 /** 30 /**
@@ -66,4 +72,32 @@ public class Player {
66 return this.maxCarryWeight; 72 return this.maxCarryWeight;
67 } 73 }
68 74
75 /**
76 * @return the nbSteps
77 */
78 public int getNbSteps() {
79 return nbSteps;
80 }
81
82 /**
83 * @param nbSteps the nbSteps to set
84 */
85 public void setNbSteps(int nbSteps) {
86 this.nbSteps = nbSteps;
87 }
88
89 /**
90 * @return the maxNbSteps
91 */
92 public int getMaxNbSteps() {
93 return maxNbSteps;
94 }
95
96 /**
97 * @param maxNbSteps the maxNbSteps to set
98 */
99 public void setMaxNbSteps(int maxNbSteps) {
100 this.maxNbSteps = maxNbSteps;
101 }
102
69} 103}