aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2014-04-06 15:12:53 +0200
committerPacien TRAN-GIRARD2014-04-06 15:12:53 +0200
commita3f6ce16e722e6d26f3ce1809a6a4f4937debe9b (patch)
treef00b9cd65b96a0f0560492831bcef90b64cd86f9 /src
parentbfbd481b9da18fb810b5dcb01dd8c8ee61d4341c (diff)
downloadesieequest-a3f6ce16e722e6d26f3ce1809a6a4f4937debe9b.tar.gz
Implements player's inventory listing
Diffstat (limited to 'src')
-rw-r--r--src/esieequest/controller/Interpreter.java3
-rw-r--r--src/esieequest/controller/Performer.java7
-rw-r--r--src/esieequest/model/items/Inventory.java7
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 }