diff options
-rw-r--r-- | src/esieequest/controller/Interpreter.java | 3 | ||||
-rw-r--r-- | src/esieequest/controller/Performer.java | 7 | ||||
-rw-r--r-- | src/esieequest/model/items/Inventory.java | 7 |
3 files changed, 17 insertions, 0 deletions
diff --git a/src/esieequest/controller/Interpreter.java b/src/esieequest/controller/Interpreter.java index 8d0f703..ea01fd7 100644 --- a/src/esieequest/controller/Interpreter.java +++ b/src/esieequest/controller/Interpreter.java | |||
@@ -72,6 +72,9 @@ class Interpreter { | |||
72 | case "eat": | 72 | case "eat": |
73 | this.performer.eat(); | 73 | this.performer.eat(); |
74 | return; | 74 | return; |
75 | case "inventory": | ||
76 | this.performer.listItems(); | ||
77 | return; | ||
75 | case "take": | 78 | case "take": |
76 | this.performer.take(command.getOption()); | 79 | this.performer.take(command.getOption()); |
77 | return; | 80 | return; |
diff --git a/src/esieequest/controller/Performer.java b/src/esieequest/controller/Performer.java index 466f9da..7f41109 100644 --- a/src/esieequest/controller/Performer.java +++ b/src/esieequest/controller/Performer.java | |||
@@ -178,4 +178,11 @@ class Performer { | |||
178 | dest.putItem(itemName, source.takeItem(itemName)); | 178 | dest.putItem(itemName, source.takeItem(itemName)); |
179 | } | 179 | } |
180 | 180 | ||
181 | /** | ||
182 | * Lists the items contained in the player's inventory. | ||
183 | */ | ||
184 | public void listItems() { | ||
185 | this.echo(Utils.list(this.game.getPlayer().getInventory().getItemList(), "Items:", "No item in your inventory.")); | ||
186 | } | ||
187 | |||
181 | } | 188 | } |
diff --git a/src/esieequest/model/items/Inventory.java b/src/esieequest/model/items/Inventory.java index 86e86b5..228386e 100644 --- a/src/esieequest/model/items/Inventory.java +++ b/src/esieequest/model/items/Inventory.java | |||
@@ -74,6 +74,13 @@ public class Inventory { | |||
74 | return Utils.list(this.items.keySet(), "Items:", "No items."); | 74 | return Utils.list(this.items.keySet(), "Items:", "No items."); |
75 | } | 75 | } |
76 | 76 | ||
77 | /** | ||
78 | * Returns the weight of the given item referred by its name. | ||
79 | * | ||
80 | * @param itemName | ||
81 | * the item's name | ||
82 | * @return | ||
83 | */ | ||
77 | public int getItemWeight(final String itemName) { | 84 | public int getItemWeight(final String itemName) { |
78 | return this.items.get(itemName).getWeight(); | 85 | return this.items.get(itemName).getWeight(); |
79 | } | 86 | } |