aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2014-04-06 13:23:02 +0000
committerPacien TRAN-GIRARD2014-04-06 13:23:02 +0000
commit7cec06bea8172ceb7d819f4d2d4474585200c74d (patch)
treef1187e4160d8ef8abff7e99fa772656b8179d750
parent52b649c665ac9f35b3e4d553bd964442dc5224c1 (diff)
parent013f9175a9ad8f103d439e1b7e61efd1e2cd43e0 (diff)
downloadesieequest-7cec06bea8172ceb7d819f4d2d4474585200c74d.tar.gz
Merge branch 'zuul-with-items' into 'master'
Zuul With Items
-rw-r--r--report/progression.tex28
-rw-r--r--src/esieequest/controller/Interpreter.java13
-rw-r--r--src/esieequest/controller/Parser.java2
-rw-r--r--src/esieequest/controller/Performer.java68
-rw-r--r--src/esieequest/controller/Utils.java40
-rw-r--r--src/esieequest/model/Game.java69
-rw-r--r--src/esieequest/model/Player.java5
-rw-r--r--src/esieequest/model/Side.java5
-rw-r--r--src/esieequest/model/command/package-info.java5
-rw-r--r--src/esieequest/model/commands/Command.java (renamed from src/esieequest/model/command/Command.java)2
-rw-r--r--src/esieequest/model/commands/CommandWord.java (renamed from src/esieequest/model/command/CommandWord.java)2
-rw-r--r--src/esieequest/model/commands/package-info.java5
-rw-r--r--src/esieequest/model/entities/Player.java69
-rw-r--r--src/esieequest/model/entities/package-info.java5
-rw-r--r--src/esieequest/model/events/Quest.java (renamed from src/esieequest/model/Quest.java)2
-rw-r--r--src/esieequest/model/events/package-info.java5
-rw-r--r--src/esieequest/model/items/Inventory.java96
-rw-r--r--src/esieequest/model/items/Item.java (renamed from src/esieequest/model/Item.java)9
-rw-r--r--src/esieequest/model/items/package-info.java5
-rw-r--r--src/esieequest/model/map/Room.java (renamed from src/esieequest/model/Room.java)72
-rw-r--r--src/esieequest/model/map/Side.java5
-rw-r--r--src/esieequest/model/map/package-info.java5
-rw-r--r--src/esieequest/view/View.java11
-rw-r--r--src/esieequest/view/app/UserInterface.java8
-rw-r--r--src/esieequest/view/text/Console.java4
-rw-r--r--src/esieequest/view/text/FileReader.java4
-rw-r--r--src/esieequest/view/text/TextInterface.java34
-rw-r--r--src/esieequest/view/web/WebInterface.java8
-rw-r--r--test/commands.txt16
29 files changed, 431 insertions, 171 deletions
diff --git a/report/progression.tex b/report/progression.tex
index 24c5d7a..94cc5b5 100644
--- a/report/progression.tex
+++ b/report/progression.tex
@@ -266,20 +266,48 @@ to win the game.
266 266
267\subsection{Player} 267\subsection{Player}
268 268
269The current room and the previous rooms were moved from Game to Player with
270commit 92f671b84.
271
269\subsection{take, drop} 272\subsection{take, drop}
270 273
274The take and drop commands were implemented as part of the commit number
2755ddb6df63. An Inventory interface, used by the Room and Player classes, was
276added. Items are stored using HashMaps, and a moveItem procedure was added to
277the Performer.
278
271\subsection{Carry several items} 279\subsection{Carry several items}
272 280
281Multiple items carrying was already implemented in the commit number 5ddb6df63.
282
273\subsection{ItemList} 283\subsection{ItemList}
274 284
285The ItemList was implemented as the Inventory class in commit number db2c22c9b.
286The Inventory is no longer an interface.
287
275\subsection{Maximum weight} 288\subsection{Maximum weight}
276 289
290The maximum carryable weight was implement with the commit number b8771ccb2.
291In order to achieve this, a getTotalWeight() function was added to the Inventory
292class.
293
277\subsection{Inventory} 294\subsection{Inventory}
278 295
296The player's inventory items listing was implemented with the commit number
297a3f6ce16e, using the recently added listing utility class.
298
279\subsection{Magic cookie} 299\subsection{Magic cookie}
280 300
301Since there are already too many commands, the carryable weight
302expansion was implemented in a smarter way using a negative weight
303item in the commit number 35ee3b1ee.
304We could have instead increased the maximum carryable weight with a setter on
305the Player class, called by the Performer with the ``eat'' command.
306
281\subsection{Tests} 307\subsection{Tests}
282 308
309The commands test file was updated in the commit number 7b610fc05.
310
283 311
284\section{Zuul with enums} 312\section{Zuul with enums}
285 313
diff --git a/src/esieequest/controller/Interpreter.java b/src/esieequest/controller/Interpreter.java
index 586b329..5c60f6d 100644
--- a/src/esieequest/controller/Interpreter.java
+++ b/src/esieequest/controller/Interpreter.java
@@ -1,7 +1,7 @@
1package esieequest.controller; 1package esieequest.controller;
2 2
3import esieequest.model.Game; 3import esieequest.model.Game;
4import esieequest.model.command.Command; 4import esieequest.model.commands.Command;
5import esieequest.view.View; 5import esieequest.view.View;
6 6
7/** 7/**
@@ -69,8 +69,14 @@ class Interpreter {
69 case "look": 69 case "look":
70 this.performer.look(); 70 this.performer.look();
71 return; 71 return;
72 case "eat": 72 case "inventory":
73 this.performer.eat(); 73 this.performer.listItems();
74 return;
75 case "take":
76 this.performer.take(command.getOption());
77 return;
78 case "drop":
79 this.performer.drop(command.getOption());
74 return; 80 return;
75 case "help": 81 case "help":
76 this.performer.showHelp(); 82 this.performer.showHelp();
@@ -83,4 +89,5 @@ class Interpreter {
83 this.performer.echo("Unknown command."); 89 this.performer.echo("Unknown command.");
84 return; 90 return;
85 } 91 }
92
86} 93}
diff --git a/src/esieequest/controller/Parser.java b/src/esieequest/controller/Parser.java
index 0f97fd1..452c27c 100644
--- a/src/esieequest/controller/Parser.java
+++ b/src/esieequest/controller/Parser.java
@@ -1,6 +1,6 @@
1package esieequest.controller; 1package esieequest.controller;
2 2
3import esieequest.model.command.Command; 3import esieequest.model.commands.Command;
4 4
5/** 5/**
6 * The command parser. 6 * The command parser.
diff --git a/src/esieequest/controller/Performer.java b/src/esieequest/controller/Performer.java
index 27cbf14..8f8afeb 100644
--- a/src/esieequest/controller/Performer.java
+++ b/src/esieequest/controller/Performer.java
@@ -1,7 +1,8 @@
1package esieequest.controller; 1package esieequest.controller;
2 2
3import esieequest.model.Game; 3import esieequest.model.Game;
4import esieequest.model.Room; 4import esieequest.model.items.Inventory;
5import esieequest.model.map.Room;
5import esieequest.view.View; 6import esieequest.view.View;
6 7
7/** 8/**
@@ -99,10 +100,10 @@ class Performer {
99 * the direction of the new room 100 * the direction of the new room
100 */ 101 */
101 public void goTo(final String direction) { 102 public void goTo(final String direction) {
102 final Room nextRoom = this.game.getRoomExit(direction); 103 final Room nextRoom = this.game.getPlayer().getCurrentRoom().getExit(direction);
103 if (nextRoom != null) { 104 if (nextRoom != null) {
104 this.game.goToRoom(nextRoom); 105 this.game.getPlayer().goToRoom(nextRoom);
105 this.view.updateRoom(this.game.getCurrentRoom()); 106 this.view.updateRoom(this.game.getPlayer().getCurrentRoom());
106 } else { 107 } else {
107 this.echo(this.game.getNoExitMessage()); 108 this.echo(this.game.getNoExitMessage());
108 } 109 }
@@ -112,22 +113,69 @@ class Performer {
112 * Changes the current room to the previous one. 113 * Changes the current room to the previous one.
113 */ 114 */
114 public void goBack() { 115 public void goBack() {
115 this.game.goToPreviousRoom(); 116 this.game.getPlayer().goToPreviousRoom();
116 this.view.updateRoom(this.game.getCurrentRoom()); 117 this.view.updateRoom(this.game.getPlayer().getCurrentRoom());
117 } 118 }
118 119
119 /** 120 /**
120 * Displays informations about the current place. 121 * Displays informations about the current place.
121 */ 122 */
122 public void look() { 123 public void look() {
123 this.echo(this.game.getCurrentRoom().getInformations()); 124 this.echo(this.game.getPlayer().getCurrentRoom().getInformations());
124 } 125 }
125 126
126 /** 127 /**
127 * Displays a special message. 128 * Moves an item from the current Room to the Player's inventory.
129 *
130 * @param itemName
131 * the item's name
132 */
133 public void take(final String itemName) {
134 int weight = this.game.getPlayer().getInventory().getTotalWeight();
135 weight += this.game.getPlayer().getCurrentRoom().getItems().getItemWeight(itemName);
136 final int maxWeight = this.game.getPlayer().getMaxCarryWeight();
137
138 if (weight >= maxWeight) {
139 this.echo("Maximum inventory weight reached. Cannot pick up item.");
140 return;
141 }
142