diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/esieequest/controller/commands/BackCommand.java | 2 | ||||
-rw-r--r-- | src/esieequest/controller/commands/DropCommand.java | 1 | ||||
-rw-r--r-- | src/esieequest/controller/commands/GoCommand.java | 2 | ||||
-rw-r--r-- | src/esieequest/controller/commands/LoadCommand.java | 2 | ||||
-rw-r--r-- | src/esieequest/controller/commands/NewCommand.java | 2 | ||||
-rw-r--r-- | src/esieequest/controller/commands/TakeCommand.java | 1 | ||||
-rw-r--r-- | src/esieequest/controller/commands/TurnCommand.java | 2 | ||||
-rw-r--r-- | src/esieequest/model/Player.java | 9 | ||||
-rw-r--r-- | src/esieequest/view/Viewable.java | 2 | ||||
-rw-r--r-- | src/esieequest/view/app/UserInterface.java | 8 | ||||
-rw-r--r-- | src/esieequest/view/text/TextInterface.java | 2 | ||||
-rw-r--r-- | src/esieequest/view/web/WebInterface.java | 6 |
12 files changed, 29 insertions, 10 deletions
diff --git a/src/esieequest/controller/commands/BackCommand.java b/src/esieequest/controller/commands/BackCommand.java index 299bda9..847d396 100644 --- a/src/esieequest/controller/commands/BackCommand.java +++ b/src/esieequest/controller/commands/BackCommand.java | |||
@@ -15,7 +15,7 @@ public class BackCommand implements Executable { | |||
15 | 15 | ||
16 | game.getPlayer().goToPreviousRoom(); | 16 | game.getPlayer().goToPreviousRoom(); |
17 | 17 | ||
18 | view.updateLocation(game.getPlayer().getCurrentRoom(), game.getPlayer().getCurrentDirection(), game.getPlayer().getCurrentSide()); | 18 | view.updateLocation(game.getPlayer().getCurrentRoom(), game.getPlayer().getCurrentDirection(), game.getPlayer().getCurrentSide(), game.getPlayer().canGoBack()); |
19 | 19 | ||
20 | } | 20 | } |
21 | 21 | ||
diff --git a/src/esieequest/controller/commands/DropCommand.java b/src/esieequest/controller/commands/DropCommand.java index 4e6f877..ee71b1e 100644 --- a/src/esieequest/controller/commands/DropCommand.java +++ b/src/esieequest/controller/commands/DropCommand.java | |||
@@ -31,6 +31,7 @@ public class DropCommand implements Executable { | |||
31 | final Item item = game.getPlayer().getInventory().takeItem(itemName); | 31 | final Item item = game.getPlayer().getInventory().takeItem(itemName); |
32 | game.getPlayer().getCurrentSide().getInventory().putItem(item); | 32 | game.getPlayer().getCurrentSide().getInventory().putItem(item); |
33 | 33 | ||
34 | view.updateLocation(game.getPlayer().getCurrentRoom(), game.getPlayer().getCurrentDirection(), game.getPlayer().getCurrentSide(), game.getPlayer().canGoBack()); | ||
34 | view.updateInventory(game.getPlayer().getInventory()); | 35 | view.updateInventory(game.getPlayer().getInventory()); |
35 | 36 | ||
36 | } | 37 | } |
diff --git a/src/esieequest/controller/commands/GoCommand.java b/src/esieequest/controller/commands/GoCommand.java index f536f64..136379f 100644 --- a/src/esieequest/controller/commands/GoCommand.java +++ b/src/esieequest/controller/commands/GoCommand.java | |||
@@ -39,7 +39,7 @@ public class GoCommand implements Executable { | |||
39 | return; | 39 | return; |
40 | } | 40 | } |
41 | 41 | ||
42 | view.updateLocation(game.getPlayer().getCurrentRoom(), direction, game.getPlayer().getCurrentSide()); | 42 | view.updateLocation(game.getPlayer().getCurrentRoom(), direction, game.getPlayer().getCurrentSide(), game.getPlayer().canGoBack()); |
43 | 43 | ||
44 | // handle challenge mode | 44 | // handle challenge mode |
45 | if (game.getPlayer().walk()) { | 45 | if (game.getPlayer().walk()) { |
diff --git a/src/esieequest/controller/commands/LoadCommand.java b/src/esieequest/controller/commands/LoadCommand.java index 8d6fd29..8a69544 100644 --- a/src/esieequest/controller/commands/LoadCommand.java +++ b/src/esieequest/controller/commands/LoadCommand.java | |||
@@ -39,7 +39,7 @@ public class LoadCommand implements Executable { | |||
39 | 39 | ||
40 | // view.updateQuest(); | 40 | // view.updateQuest(); |
41 | // view.updateInventory(game.getPlayer().getItems()); | 41 | // view.updateInventory(game.getPlayer().getItems()); |
42 | view.updateLocation(game.getPlayer().getCurrentRoom(), game.getPlayer().getCurrentDirection(), game.getPlayer().getCurrentSide()); | 42 | view.updateLocation(game.getPlayer().getCurrentRoom(), game.getPlayer().getCurrentDirection(), game.getPlayer().getCurrentSide(), game.getPlayer().canGoBack()); |
43 | 43 | ||
44 | } | 44 | } |
45 | 45 | ||
diff --git a/src/esieequest/controller/commands/NewCommand.java b/src/esieequest/controller/commands/NewCommand.java index 4ce45d0..e0e45ab 100644 --- a/src/esieequest/controller/commands/NewCommand.java +++ b/src/esieequest/controller/commands/NewCommand.java | |||
@@ -24,7 +24,7 @@ public class NewCommand implements Executable { | |||
24 | 24 | ||
25 | view.enable(); | 25 | view.enable(); |
26 | 26 | ||
27 | view.updateLocation(game.getPlayer().getCurrentRoom(), game.getPlayer().getCurrentDirection(), game.getPlayer().getCurrentSide()); | 27 | view.updateLocation(game.getPlayer().getCurrentRoom(), game.getPlayer().getCurrentDirection(), game.getPlayer().getCurrentSide(), game.getPlayer().canGoBack()); |
28 | view.echo(Text.WELCOME.toString()); | 28 | view.echo(Text.WELCOME.toString()); |
29 | 29 | ||
30 | } | 30 | } |
diff --git a/src/esieequest/controller/commands/TakeCommand.java b/src/esieequest/controller/commands/TakeCommand.java index 4e615c7..b92f4e5 100644 --- a/src/esieequest/controller/commands/TakeCommand.java +++ b/src/esieequest/controller/commands/TakeCommand.java | |||
@@ -47,6 +47,7 @@ public class TakeCommand implements Executable { | |||
47 | game.getPlayer().getCurrentRoom().removeItem(item); | 47 | game.getPlayer().getCurrentRoom().removeItem(item); |
48 | game.getPlayer().getInventory().putItem(item); | 48 | game.getPlayer().getInventory().putItem(item); |
49 | 49 | ||
50 | view.updateLocation(game.getPlayer().getCurrentRoom(), game.getPlayer().getCurrentDirection(), game.getPlayer().getCurrentSide(), game.getPlayer().canGoBack()); | ||
50 | view.updateInventory(game.getPlayer().getInventory()); | 51 | view.updateInventory(game.getPlayer().getInventory()); |
51 | 52 | ||
52 | } | 53 | } |
diff --git a/src/esieequest/controller/commands/TurnCommand.java b/src/esieequest/controller/commands/TurnCommand.java index d4b6ee9..f985087 100644 --- a/src/esieequest/controller/commands/TurnCommand.java +++ b/src/esieequest/controller/commands/TurnCommand.java | |||
@@ -30,7 +30,7 @@ public class TurnCommand implements Executable { | |||
30 | final Direction newDirection = currentDirection.rotate(orientation); | 30 | final Direction newDirection = currentDirection.rotate(orientation); |
31 | game.getPlayer().setCurrentDirection(newDirection); | 31 | game.getPlayer().setCurrentDirection(newDirection); |
32 | 32 | ||
33 | view.updateLocation(game.getPlayer().getCurrentRoom(), newDirection, game.getPlayer().getCurrentSide()); | 33 | view.updateLocation(game.getPlayer().getCurrentRoom(), newDirection, game.getPlayer().getCurrentSide(), game.getPlayer().canGoBack()); |
34 | 34 | ||
35 | } | 35 | } |
36 | 36 | ||
diff --git a/src/esieequest/model/Player.java b/src/esieequest/model/Player.java index ea8af35..23e3a54 100644 --- a/src/esieequest/model/Player.java +++ b/src/esieequest/model/Player.java | |||
@@ -102,6 +102,15 @@ public class Player implements SerialisableObject { | |||
102 | } | 102 | } |
103 | 103 | ||
104 | /** | 104 | /** |
105 | * Tells if the Player can go back. | ||
106 | * | ||
107 | * @return false if the Player's Room history is empty. | ||
108 | */ | ||
109 | public boolean canGoBack() { | ||
110 | return !this.previousRooms.isEmpty(); | ||
111 | } | ||
112 | |||
113 | /** | ||
105 | * Clears the previous rooms history. | 114 | * Clears the previous rooms history. |
106 | */ | 115 | */ |
107 | public void clearRoomHistory() { | 116 | public void clearRoomHistory() { |
diff --git a/src/esieequest/view/Viewable.java b/src/esieequest/view/Viewable.java index d4da79b..eb9c50a 100644 --- a/src/esieequest/view/Viewable.java +++ b/src/esieequest/view/Viewable.java | |||
@@ -63,7 +63,7 @@ public interface Viewable { | |||
63 | * @param side | 63 | * @param side |
64 | * the side of a room | 64 | * the side of a room |
65 | */ | 65 | */ |
66 | public void updateLocation(final Room room, final Direction direction, final Side side); | 66 | public void updateLocation(final Room room, final Direction direction, final Side side, final boolean canGoBack); |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Updates the view to display the items contained in the inventory | 69 | * Updates the view to display the items contained in the inventory |
diff --git a/src/esieequest/view/app/UserInterface.java b/src/esieequest/view/app/UserInterface.java index 1d73e79..220afc1 100644 --- a/src/esieequest/view/app/UserInterface.java +++ b/src/esieequest/view/app/UserInterface.java | |||
@@ -418,9 +418,13 @@ abstract class UserInterface implements Viewable, ActionListener { | |||
418 | } | 418 | } |
419 | 419 | ||
420 | @Override | 420 | @Override |
421 | public void updateLocation(final Room room, final Direction direction, final Side side) { | 421 | public void updateLocation(final Room room, final Direction direction, final Side side, final boolean canGoBack) { |
422 | this.echo(room.getInformations()); | ||
423 | this.setIllustration(room.name() + Text.FILENAME_SEPARATOR.toString() + direction.name()); | 422 | this.setIllustration(room.name() + Text.FILENAME_SEPARATOR.toString() + direction.name()); |
423 | this.backButton.setEnabled(canGoBack); | ||
424 | this.forwardButton.setEnabled(side.hasDoor()); | ||
425 | this.actionButton.setEnabled(side.hasCharacter() || side.getInventory().getSize() > 0); | ||
426 | |||
427 | this.echo(room.getInformations()); | ||
424 | } | 428 | } |
425 | 429 | ||
426 | @Override | 430 | @Override |
diff --git a/src/esieequest/view/text/TextInterface.java b/src/esieequest/view/text/TextInterface.java index 5e701d3..3fc0399 100644 --- a/src/esieequest/view/text/TextInterface.java +++ b/src/esieequest/view/text/TextInterface.java | |||
@@ -87,7 +87,7 @@ abstract class TextInterface implements Viewable { | |||
87 | } | 87 | } |
88 | 88 | ||
89 | @Override | 89 | @Override |
90 | public void updateLocation(final Room room, final Direction direction, final Side side) { | 90 | public void updateLocation(final Room room, final Direction direction, final Side side, final boolean canGoBack) { |
91 | this.echo(room.getInformations()); | 91 | this.echo(room.getInformations()); |
92 | } | 92 | } |
93 | 93 | ||
diff --git a/src/esieequest/view/web/WebInterface.java b/src/esieequest/view/web/WebInterface.java index 07bb60a..fe67b72 100644 --- a/src/esieequest/view/web/WebInterface.java +++ b/src/esieequest/view/web/WebInterface.java | |||
@@ -327,8 +327,12 @@ class WebInterface extends Composite implements Viewable { | |||
327 | } | 327 | } |
328 | 328 | ||
329 | @Override | 329 | @Override |
330 | public void updateLocation(final Room room, final Direction direction, final Side side) { | 330 | public void updateLocation(final Room room, final Direction direction, final Side side, final boolean canGoBack) { |
331 | this.setIllustration(room.name() + Text.FILENAME_SEPARATOR.toString() + direction.name()); | 331 | this.setIllustration(room.name() + Text.FILENAME_SEPARATOR.toString() + direction.name()); |
332 | this.backButton.setEnabled(canGoBack); | ||
333 | this.forwardButton.setEnabled(side.hasDoor()); | ||
334 | this.actionButton.setEnabled(side.hasCharacter() || side.getInventory().getSize() > 0); | ||
335 | |||
332 | this.echo(room.getInformations()); | 336 | this.echo(room.getInformations()); |
333 | } | 337 | } |
334 | 338 | ||