aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--report/progression.tex10
-rwxr-xr-xsrc/esieequest/Main.java22
-rw-r--r--src/esieequest/controller/GameEngine.java28
-rw-r--r--src/esieequest/controller/Interpreter.java42
-rw-r--r--src/esieequest/controller/Parser.java18
-rw-r--r--src/esieequest/controller/Performer.java64
-rw-r--r--src/esieequest/model/Game.java66
-rw-r--r--src/esieequest/model/Item.java54
-rw-r--r--src/esieequest/model/Room.java63
-rw-r--r--src/esieequest/model/command/Command.java18
-rw-r--r--src/esieequest/model/command/CommandWord.java16
-rw-r--r--src/esieequest/view/View.java6
-rw-r--r--src/esieequest/view/app/Applet.java8
-rw-r--r--src/esieequest/view/app/UserInterface.java345
-rw-r--r--src/esieequest/view/app/Window.java12
-rw-r--r--src/esieequest/view/console/Console.java28
-rw-r--r--src/esieequest/view/web/Main.java6
-rw-r--r--src/esieequest/view/web/WebInterface.java22
18 files changed, 475 insertions, 353 deletions
diff --git a/report/progression.tex b/report/progression.tex
index 215ab82..6600430 100644
--- a/report/progression.tex
+++ b/report/progression.tex
@@ -183,12 +183,22 @@ separate the logic from the data storage as part of commit bd639caa0.
183 183
184\subsection{Item} 184\subsection{Item}
185 185
186Item support was added as part of commit 3fc06f393.
187
186\subsection{item description} 188\subsection{item description}
187 189
190In order to respect the MVC pattern, the Performer controller should get the
191description from the Item model and ask the View to display it.
192
188\subsection{items} 193\subsection{items}
189 194
195A Room can contain multiple items since commit 04f03d128.
196
190\subsection{Collection choice} 197\subsection{Collection choice}
191 198
199The collection chosen to implement the multiple items support was the HashMap in
200order to associate an item name (String) to an Item, so that the user is able
201to perform actions on a particular one (take, drop, use, etc\ldots).
192 202
193\section{Zuul with history} 203\section{Zuul with history}
194 204
diff --git a/src/esieequest/Main.java b/src/esieequest/Main.java
index 5a08f1d..b4bfb59 100755
--- a/src/esieequest/Main.java
+++ b/src/esieequest/Main.java
@@ -25,28 +25,28 @@ public class Main extends JApplet {
25 /** 25 /**
26 * 26 *
27 */ 27 */
28 private static final long serialVersionUID = 1726402114771940798L; 28 private static long serialVersionUID = 1726402114771940798L;
29 29
30 public void init() { 30 public void init() {
31 // applet 31 // applet
32 Game vGame = new Game(); 32 Game game = new Game();
33 Applet vApplet = new Applet(this); 33 Applet applet = new Applet(this);
34 new GameEngine(vGame, vApplet); 34 new GameEngine(game, applet);
35 } 35 }
36 36
37 public static void main(final String[] pArgs) { 37 public static void main(String[] args) {
38 // cli or standalone 38 // cli or standalone
39 Game vGame = new Game(); 39 Game game = new Game();
40 View vView; 40 View view;
41 41
42 if (Arrays.asList(pArgs).contains("--nogui")) { 42 if (Arrays.asList(args).contains("--nogui")) {
43 vView = new Console(); 43 view = new Console();
44 44
45 } else { 45 } else {
46 vView = new Window(); 46 view = new Window();
47 } 47 }
48 48
49 new GameEngine(vGame, vView); 49 new GameEngine(game, view);
50 } 50 }
51 51
52} 52}
diff --git a/src/esieequest/controller/GameEngine.java b/src/esieequest/controller/GameEngine.java
index 3999cd0..4a1f47f 100644
--- a/src/esieequest/controller/GameEngine.java
+++ b/src/esieequest/controller/GameEngine.java
@@ -14,35 +14,35 @@ import esieequest.view.View;
14 */ 14 */
15public class GameEngine { 15public class GameEngine {
16 16
17 private Game aGame; 17 private Game game;
18 private View aView; 18 private View view;
19 19
20 private Interpreter aInterpreter; 20 private Interpreter interpreter;
21 21
22 public GameEngine(final Game pGame, final View pView) { 22 public GameEngine(Game game, View view) {
23 this.aGame = pGame; 23 this.game = game;
24 this.aView = pView; 24 this.view = view;
25 25
26 this.aView.setModel(pGame); 26 this.view.setModel(game);
27 this.aView.setController(this); 27 this.view.setController(this);
28 28
29 this.aInterpreter = new Interpreter(this.aGame, this.aView); 29 this.interpreter = new Interpreter(this.game, this.view);
30 30
31 this.startGame(); 31 this.startGame();
32 this.startView(); 32 this.startView();
33 } 33 }
34 34
35 private void startGame() { 35 private void startGame() {
36 this.aGame.setRunning(true); 36 this.game.setRunning(true);
37 this.aInterpreter.interpret("new"); 37 this.interpreter.interpret("new");
38 } 38 }
39 39
40 private void startView() { 40 private void startView() {
41 this.aView.enable(); 41 this.view.enable();
42 } 42 }
43 43
44 public void interpret(final String pCommandString) { 44 public void interpret(String commandString) {
45 this.aInterpreter.interpret(pCommandString); 45 this.interpreter.interpret(commandString);
46 } 46 }
47 47
48} 48}
diff --git a/src/esieequest/controller/Interpreter.java b/src/esieequest/controller/Interpreter.java
index b4fbb3e..55d468b 100644
--- a/src/esieequest/controller/Interpreter.java
+++ b/src/esieequest/controller/Interpreter.java
@@ -13,52 +13,52 @@ import esieequest.view.View;
13 */ 13 */
14public class Interpreter { 14public class Interpreter {
15 15
16 private Performer aPerformer; 16 private Performer performer;
17 private Parser aParser; 17 private Parser parser;
18 18
19 public Interpreter(final Game pGame, final View pView) { 19 public Interpreter(Game game, View view) {
20 this.aPerformer = new Performer(pGame, pView); 20 this.performer = new Performer(game, view);
21 this.aParser = new Parser(); 21 this.parser = new Parser();
22 } 22 }
23 23
24 public void interpret(String pCommandString) { 24 public void interpret(String commandString) {
25 Command vCommand = this.aParser.getCommand(pCommandString); 25 Command command = this.parser.getCommand(commandString);
26 this.dispatch(vCommand); 26 this.dispatch(command);
27 } 27 }
28 28
29 public void dispatch(final Command pCommand) { 29 public void dispatch(Command command) {
30 if (pCommand.getAction() != null) { 30 if (command.getAction() != null) {
31 switch (pCommand.getAction()) { 31 switch (command.getAction()) {
32 case "new": 32 case "new":
33 this.aPerformer.newGame(); 33 this.performer.newGame();
34 return; 34 return;
35 case "load": 35 case "load":
36 this.aPerformer.loadGame(); 36 this.performer.loadGame();
37 return; 37 return;
38 case "save": 38 case "save":
39 this.aPerformer.saveGame(); 39 this.performer.saveGame();
40 return; 40 return;
41 case "sound": 41 case "sound":
42 this.aPerformer.toggleSound(); 42 this.performer.toggleSound();
43 return; 43 return;
44 case "go": 44 case "go":
45 this.aPerformer.goTo(pCommand.getOption()); 45 this.performer.goTo(command.getOption());
46 return; 46 return;
47 case "look": 47 case "look":
48 this.aPerformer.look(); 48 this.performer.look();
49 return; 49 return;
50 case "eat": 50 case "eat":
51 this.aPerformer.eat(); 51 this.performer.eat();
52 return; 52 return;
53