aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2014-04-02 08:18:56 +0000
committerPacien TRAN-GIRARD2014-04-02 08:18:56 +0000
commit52b649c665ac9f35b3e4d553bd964442dc5224c1 (patch)
treeb0f7de122d2c8b56760dcadd2aa628bfa27849c7
parent4137433c5b57720d00cb249715e0ec252a99a173 (diff)
parentf5f6260f41fc16ee9abcae8bb2f26c45d8e29efa (diff)
downloadesieequest-52b649c665ac9f35b3e4d553bd964442dc5224c1.tar.gz
Merge branch 'zuul-mcv' into 'master'
Zuul Mcv 2
-rw-r--r--src/esieequest/controller/GameEngine.java1
-rw-r--r--src/esieequest/controller/Performer.java6
-rw-r--r--src/esieequest/model/Game.java29
-rw-r--r--src/esieequest/model/Quest.java22
-rw-r--r--src/esieequest/model/Side.java5
-rw-r--r--src/esieequest/model/command/CommandWord.java38
-rw-r--r--src/esieequest/view/text/FileReader.java8
-rw-r--r--src/esieequest/view/web/WebInterface.ui.xml7
8 files changed, 67 insertions, 49 deletions
diff --git a/src/esieequest/controller/GameEngine.java b/src/esieequest/controller/GameEngine.java
index 01cf8c4..c09967b 100644
--- a/src/esieequest/controller/GameEngine.java
+++ b/src/esieequest/controller/GameEngine.java
@@ -28,7 +28,6 @@ public class GameEngine {
28 this.game = game; 28 this.game = game;
29 this.view = view; 29 this.view = view;
30 30
31 this.view.setModel(game);
32 this.view.setController(this); 31 this.view.setController(this);
33 32
34 this.interpreter = new Interpreter(this.game, this.view); 33 this.interpreter = new Interpreter(this.game, this.view);
diff --git a/src/esieequest/controller/Performer.java b/src/esieequest/controller/Performer.java
index 0ac194f..27cbf14 100644
--- a/src/esieequest/controller/Performer.java
+++ b/src/esieequest/controller/Performer.java
@@ -102,7 +102,7 @@ class Performer {
102 final Room nextRoom = this.game.getRoomExit(direction); 102 final Room nextRoom = this.game.getRoomExit(direction);
103 if (nextRoom != null) { 103 if (nextRoom != null) {
104 this.game.goToRoom(nextRoom); 104 this.game.goToRoom(nextRoom);
105 this.echo(this.game.getLocationInfo()); 105 this.view.updateRoom(this.game.getCurrentRoom());
106 } else { 106 } else {
107 this.echo(this.game.getNoExitMessage()); 107 this.echo(this.game.getNoExitMessage());
108 } 108 }
@@ -113,14 +113,14 @@ class Performer {
113 */ 113 */
114 public void goBack() { 114 public void goBack() {
115 this.game.goToPreviousRoom(); 115 this.game.goToPreviousRoom();
116 this.echo(this.game.getLocationInfo()); 116 this.view.updateRoom(this.game.getCurrentRoom());
117 } 117 }
118 118
119 /** 119 /**
120 * Displays informations about the current place. 120 * Displays informations about the current place.
121 */ 121 */
122 public void look() { 122 public void look() {
123 this.echo(this.game.getLocationInfo()); 123 this.echo(this.game.getCurrentRoom().getInformations());
124 } 124 }
125 125
126 /** 126 /**
diff --git a/src/esieequest/model/Game.java b/src/esieequest/model/Game.java
index f7b773b..62dfc94 100644
--- a/src/esieequest/model/Game.java
+++ b/src/esieequest/model/Game.java
@@ -13,6 +13,7 @@ public class Game {
13 13
14 private final HashMap<String, Room> rooms; 14 private final HashMap<String, Room> rooms;
15 private Room currentRoom; 15 private Room currentRoom;
16
16 private final Stack<Room> previousRooms; 17 private final Stack<Room> previousRooms;
17 18
18 /** 19 /**
@@ -214,6 +215,15 @@ public class Game {
214 } 215 }
215 216
216 /** 217 /**
218 * Returns the current room.
219 *
220 * @return the current room
221 */
222 public Room getCurrentRoom() {
223 return this.currentRoom;
224 }
225
226 /**
217 * Returns the current room's exit located in the given direction. 227 * Returns the current room's exit located in the given direction.
218 * 228 *
219 * @param direction 229 * @param direction
@@ -226,25 +236,6 @@ public class Game {
226 } 236 }
227 237
228 /** 238 /**
229 * Returns informations about the current room (description, exits and
230 * items).
231 *
232 * @return the informations about the current room
233 */
234 public String getLocationInfo() {
235 return this.currentRoom.getInformations();
236 }
237
238 /**
239 * Returns the current room's image name.
240 *
241 * @return the current room's image name.
242 */
243 public String getLocationImageName() {
244 return this.currentRoom.getImageName();
245 }
246
247 /**
248 * Returns the "eat" message. 239 * Returns the "eat" message.
249 * 240 *
250 * @return the "eat message 241 * @return the "eat message
diff --git a/src/esieequest/model/Quest.java b/src/esieequest/model/Quest.java
new file mode 100644
index 0000000..1f4a9cc
--- /dev/null
+++ b/src/esieequest/model/Quest.java
@@ -0,0 +1,22 @@
1package esieequest.model;
2
3public class Quest {
4
5 private String title;
6
7 /**
8 * @return the title
9 */
10 public String getTitle() {
11 return this.title;
12 }
13
14 /**
15 * @param title
16 * the title to set
17 */
18 public void setTitle(final String title) {
19 this.title = title;
20 }
21
22}
diff --git a/src/esieequest/model/Side.java b/src/esieequest/model/Side.java
new file mode 100644
index 0000000..cb4e545
--- /dev/null
+++ b/src/esieequest/model/Side.java
@@ -0,0 +1,5 @@
1package esieequest.model;
2
3public class Side {
4
5}
diff --git a/src/esieequest/model/command/CommandWord.java b/src/esieequest/model/command/CommandWord.java
index b96bcef..270cc49 100644
--- a/src/esieequest/model/command/CommandWord.java
+++ b/src/esieequest/model/command/CommandWord.java
@@ -8,25 +8,25 @@ package esieequest.model.command;
8public enum CommandWord { 8public enum CommandWord {
9 9
10 // @formatter:off 10 // @formatter:off
11 // COMMAND ARGUMENTS ("" = no one ; null = any) 11 // COMMAND ARGUMENTS ("" = no one ; null = any)
12 NEW( "new", new String[] { "" }), 12 NEW ( "new", new String[] { "" } ),
13 LOAD( "load", new String[] { "" }), 13 LOAD ( "load", new String[] { "" } ),
14 SAVE( "save", new String[] { "" }), 14 SAVE ( "save", new String[] { "" } ),
15 SOUND( "sound", new String[] { "" }), 15 SOUND ( "sound", new String[] { "" } ),
16 HELP( "help", new String[] { "" }), 16 HELP ( "help", new String[] { "" } ),
17 QUIT( "quit", new String[] { "" }), 17 QUIT ( "quit", new String[] { "" } ),
18 LOOK( "look", new String[] { "" }), 18 LOOK ( "look", new String[] { "" } ),
19 EAT( "eat", new String[] { "" }), 19 EAT ( "eat", new String[] { "" } ),
20 FORWARD( "forward", new String[] { "" }), 20 FORWARD ( "forward", new String[] { "" } ),
21 BACK( "back", new String[] { "" }), 21 BACK ( "back", new String[] { "" } ),
22 GO( "go", new String[] { "north", "south", "east", "west", "up", "down" }), 22 GO ( "go", new String[] { "north", "south", "east", "west", "up", "down" } ),
23 TURN( "turn", new String[] { "left", "right" }), 23 TURN ( "turn", new String[] { "left", "right" } ),
24 DO( "do", new String[] { "" }), 24 DO ( "do", new String[] { "" } ),
25 TAKE( "take", new String[] { "" }), 25 TAKE ( "take", new String[] { "" } ),
26 TALK( "talk", new String[] { "" }), 26 TALK ( "talk", new String[] { "" } ),
27 INVENTORY( "inventory", new String[] { "" }), 27 INVENTORY ( "inventory", new String[] { "" } ),
28 USE( "use", null), 28 USE ( "use", null ),
29 UNKNOWN( "?", new String[] { "" }); 29 UNKNOWN ( "?", new String[] { "" } );
30 // @formatter:on 30 // @formatter:on
31 31
32 private String action; 32 private String action;
diff --git a/src/esieequest/view/text/FileReader.java b/src/esieequest/view/text/FileReader.java
index f063a69..392a691 100644
--- a/src/esieequest/view/text/FileReader.java
+++ b/src/esieequest/view/text/FileReader.java
@@ -11,7 +11,7 @@ import java.util.Scanner;
11 */ 11 */
12public class FileReader extends TextInterface { 12public class FileReader extends TextInterface {
13 13
14 private File file; 14 private final File file;
15 15
16 /** 16 /**
17 * The FileReader initialiser. 17 * The FileReader initialiser.
@@ -30,16 +30,16 @@ public class FileReader extends TextInterface {
30 @Override 30 @Override
31 protected void run() { 31 protected void run() {
32 try { 32 try {
33 final Scanner scanner = new Scanner(file); 33 final Scanner scanner = new Scanner(this.file);
34 while (this.running && scanner.hasNextLine()) { 34 while (this.running && scanner.hasNextLine()) {
35 String line = scanner.nextLine(); 35 final String line = scanner.nextLine();