diff options
Diffstat (limited to 'src')
28 files changed, 189 insertions, 74 deletions
diff --git a/src/esieequest/controller/commands/BackCommand.java b/src/esieequest/controller/commands/BackCommand.java index 847d396..d7ed8a3 100644 --- a/src/esieequest/controller/commands/BackCommand.java +++ b/src/esieequest/controller/commands/BackCommand.java | |||
@@ -15,7 +15,9 @@ 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(), game.getPlayer().canGoBack()); | 18 | view.updateLocation(game.getPlayer().getCurrentRoom(), game.getPlayer() |
19 | .getCurrentDirection(), game.getPlayer().getCurrentSide(), game.getPlayer() | ||
20 | .canGoBack()); | ||
19 | 21 | ||
20 | } | 22 | } |
21 | 23 | ||
diff --git a/src/esieequest/controller/commands/Command.java b/src/esieequest/controller/commands/Command.java index ca8909c..0879bef 100644 --- a/src/esieequest/controller/commands/Command.java +++ b/src/esieequest/controller/commands/Command.java | |||
@@ -94,7 +94,8 @@ public enum Command { | |||
94 | * @return a String listing all the names of the Command-s | 94 | * @return a String listing all the names of the Command-s |
95 | */ | 95 | */ |
96 | public static String listCommandsNamesString() { | 96 | public static String listCommandsNamesString() { |
97 | return ListUtils.listToString(Command.listCommandsNames(), Text.HELP_PREFIX.toString(), null, Text.HELP_SUFFIX.toString()); | 97 | return ListUtils.listToString(Command.listCommandsNames(), Text.HELP_PREFIX.toString(), |
98 | null, Text.HELP_SUFFIX.toString()); | ||
98 | } | 99 | } |
99 | 100 | ||
100 | } | 101 | } |
diff --git a/src/esieequest/controller/commands/DropCommand.java b/src/esieequest/controller/commands/DropCommand.java index ee71b1e..dbdf03c 100644 --- a/src/esieequest/controller/commands/DropCommand.java +++ b/src/esieequest/controller/commands/DropCommand.java | |||
@@ -31,7 +31,9 @@ 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.updateLocation(game.getPlayer().getCurrentRoom(), game.getPlayer() |
35 | .getCurrentDirection(), game.getPlayer().getCurrentSide(), game.getPlayer() | ||
36 | .canGoBack()); | ||
35 | view.updateInventory(game.getPlayer().getInventory()); | 37 | view.updateInventory(game.getPlayer().getInventory()); |
36 | 38 | ||
37 | } | 39 | } |
diff --git a/src/esieequest/controller/commands/GoCommand.java b/src/esieequest/controller/commands/GoCommand.java index 136379f..1078d49 100644 --- a/src/esieequest/controller/commands/GoCommand.java +++ b/src/esieequest/controller/commands/GoCommand.java | |||
@@ -39,7 +39,8 @@ public class GoCommand implements Executable { | |||
39 | return; | 39 | return; |
40 | } | 40 | } |
41 | 41 | ||
42 | view.updateLocation(game.getPlayer().getCurrentRoom(), direction, game.getPlayer().getCurrentSide(), game.getPlayer().canGoBack()); | 42 | view.updateLocation(game.getPlayer().getCurrentRoom(), direction, game.getPlayer() |
43 | .getCurrentSide(), game.getPlayer().canGoBack()); | ||
43 | 44 | ||
44 | // handle challenge mode | 45 | // handle challenge mode |
45 | if (game.getPlayer().walk()) { | 46 | if (game.getPlayer().walk()) { |
diff --git a/src/esieequest/controller/commands/InventoryCommand.java b/src/esieequest/controller/commands/InventoryCommand.java index a6ce080..27936ce 100644 --- a/src/esieequest/controller/commands/InventoryCommand.java +++ b/src/esieequest/controller/commands/InventoryCommand.java | |||
@@ -13,7 +13,8 @@ public class InventoryCommand implements Executable { | |||
13 | @Override | 13 | @Override |
14 | public void execute(final String argument, final Game game, final Viewable view) { | 14 | public void execute(final String argument, final Game game, final Viewable view) { |
15 | 15 | ||
16 | view.echo(game.getPlayer().getInventory().listItemsNamesString() + game.getPlayer().getInventory().getWeightString()); | 16 | view.echo(game.getPlayer().getInventory().listItemsNamesString() |
17 | + game.getPlayer().getInventory().getWeightString()); | ||
17 | 18 | ||
18 | } | 19 | } |
19 | 20 | ||
diff --git a/src/esieequest/controller/commands/LoadCommand.java b/src/esieequest/controller/commands/LoadCommand.java index 8a69544..896d85b 100644 --- a/src/esieequest/controller/commands/LoadCommand.java +++ b/src/esieequest/controller/commands/LoadCommand.java | |||
@@ -24,7 +24,8 @@ public class LoadCommand implements Executable { | |||
24 | try { | 24 | try { |
25 | datas = (JSONObject) JSONValue.parseWithException(jsonString); | 25 | datas = (JSONObject) JSONValue.parseWithException(jsonString); |
26 | } catch (final ParseException e) { | 26 | } catch (final ParseException e) { |
27 | view.echo(Text.PARSING_ERROR_PREFIX.toString() + e.getMessage() + Text.PARSING_ERROR_SUFFIX.toString()); | 27 | view.echo(Text.PARSING_ERROR_PREFIX.toString() + e.getMessage() |
28 | + Text.PARSING_ERROR_SUFFIX.toString()); | ||
28 | return; | 29 | return; |
29 | } | 30 | } |
30 | 31 | ||
@@ -32,14 +33,17 @@ public class LoadCommand implements Executable { | |||
32 | game.newGame(false, false); | 33 | game.newGame(false, false); |
33 | game.deserialise(datas); | 34 | game.deserialise(datas); |
34 | } catch (final Exception e) { | 35 | } catch (final Exception e) { |
35 | view.echo(Text.DESERIALISING_ERROR_PREFIX.toString() + e.getMessage() + Text.DESERIALISING_ERROR_SUFFIX.toString()); | 36 | view.echo(Text.DESERIALISING_ERROR_PREFIX.toString() + e.getMessage() |
37 | + Text.DESERIALISING_ERROR_SUFFIX.toString()); | ||
36 | e.printStackTrace(); | 38 | e.printStackTrace(); |
37 | return; | 39 | return; |
38 | } | 40 | } |
39 | 41 | ||
40 | // view.updateQuest(); | 42 | // view.updateQuest(); |
41 | // view.updateInventory(game.getPlayer().getItems()); | 43 | // view.updateInventory(game.getPlayer().getItems()); |
42 | view.updateLocation(game.getPlayer().getCurrentRoom(), game.getPlayer().getCurrentDirection(), game.getPlayer().getCurrentSide(), game.getPlayer().canGoBack()); | 44 | view.updateLocation(game.getPlayer().getCurrentRoom(), game.getPlayer() |
45 | .getCurrentDirection(), game.getPlayer().getCurrentSide(), game.getPlayer() | ||
46 | .canGoBack()); | ||
43 | 47 | ||
44 | } | 48 | } |
45 | 49 | ||
diff --git a/src/esieequest/controller/commands/LookCommand.java b/src/esieequest/controller/commands/LookCommand.java index ece4ddc..305934f 100644 --- a/src/esieequest/controller/commands/LookCommand.java +++ b/src/esieequest/controller/commands/LookCommand.java | |||
@@ -21,7 +21,9 @@ public class LookCommand implements Executable { | |||
21 | final ArrayList<String> informations = new ArrayList<String>(); | 21 | final ArrayList<String> informations = new ArrayList<String>(); |
22 | 22 | ||
23 | informations.add(game.getPlayer().getCurrentRoom().getInformations()); | 23 | informations.add(game.getPlayer().getCurrentRoom().getInformations()); |
24 | informations.add(Text.DIRECTION_PREFIX + game.getPlayer().getCurrentDirection().name().toLowerCase() + Text.DIRECTION_SUFFIX); | 24 | informations.add(Text.DIRECTION_PREFIX |
25 | + game.getPlayer().getCurrentDirection().name().toLowerCase() | ||
26 | + Text.DIRECTION_SUFFIX); | ||
25 | 27 | ||
26 | view.echo(Joiner.on(Text.NEW_LINE.toString()).join(informations)); | 28 | view.echo(Joiner.on(Text.NEW_LINE.toString()).join(informations)); |
27 | 29 | ||
diff --git a/src/esieequest/controller/commands/NewCommand.java b/src/esieequest/controller/commands/NewCommand.java index e0e45ab..3f0b4b9 100644 --- a/src/esieequest/controller/commands/NewCommand.java +++ b/src/esieequest/controller/commands/NewCommand.java | |||
@@ -24,7 +24,9 @@ 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(), game.getPlayer().canGoBack()); | 27 | view.updateLocation(game.getPlayer().getCurrentRoom(), game.getPlayer() |
28 | .getCurrentDirection(), game.getPlayer().getCurrentSide(), game.getPlayer() | ||
29 | .canGoBack()); | ||
28 | view.echo(Text.WELCOME.toString()); | 30 | view.echo(Text.WELCOME.toString()); |
29 | 31 | ||
30 | } | 32 | } |
diff --git a/src/esieequest/controller/commands/TakeCommand.java b/src/esieequest/controller/commands/TakeCommand.java index b92f4e5..9f70f98 100644 --- a/src/esieequest/controller/commands/TakeCommand.java +++ b/src/esieequest/controller/commands/TakeCommand.java | |||
@@ -38,7 +38,8 @@ public class TakeCommand implements Executable { | |||
38 | 38 | ||
39 | // handle inventory weight limit | 39 | // handle inventory weight limit |
40 | final int maximumWeight = game.getPlayer().getInventoryWeightLimit(); | 40 | final int maximumWeight = game.getPlayer().getInventoryWeightLimit(); |
41 | final int futureWeight = game.getPlayer().getInventory().getTotalWeight() + item.getWeight(); | 41 | final int futureWeight = game.getPlayer().getInventory().getTotalWeight() |
42 | + item.getWeight(); | ||
42 | if (futureWeight > maximumWeight) { | 43 | if (futureWeight > maximumWeight) { |
43 | view.echo(Text.INVENTORY_FULL.toString()); | 44 | view.echo(Text.INVENTORY_FULL.toString()); |
44 | return; | 45 | return; |
@@ -47,7 +48,9 @@ public class TakeCommand implements Executable { | |||
47 | game.getPlayer().getCurrentRoom().removeItem(item); | 48 | game.getPlayer().getCurrentRoom().removeItem(item); |
48 | game.getPlayer().getInventory().putItem(item); | 49 | game.getPlayer().getInventory().putItem(item); |
49 | 50 | ||
50 | view.updateLocation(game.getPlayer().get |