aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2014-04-19 14:41:30 +0200
committerPacien TRAN-GIRARD2014-04-19 14:42:52 +0200
commit86d6f56dd14fdb94411a02679b9ad4bd556d8a32 (patch)
tree7f3f287b861f54d523d4643b3a349752c01bec32
parent006daa5c112fd9a5e3bdc38d760ba22b2558651c (diff)
downloadesieequest-86d6f56dd14fdb94411a02679b9ad4bd556d8a32.tar.gz
Refactoring + implement Sides
-rw-r--r--.classpath2
-rw-r--r--lib/guava-16.0.1.jarbin0 -> 2228009 bytes
-rw-r--r--lib/guava-gwt-16.0.1.jarbin0 -> 837282 bytes
-rwxr-xr-xsrc/esieequest/Main.java6
-rw-r--r--src/esieequest/controller/GameEngine.java33
-rw-r--r--src/esieequest/controller/Input.java59
-rw-r--r--src/esieequest/controller/Interpreter.java110
-rw-r--r--src/esieequest/controller/Parser.java46
-rw-r--r--src/esieequest/controller/Performer.java320
-rw-r--r--src/esieequest/controller/Utils.java55
-rw-r--r--src/esieequest/controller/commands/AleaCommand.java39
-rw-r--r--src/esieequest/controller/commands/BackCommand.java21
-rw-r--r--src/esieequest/controller/commands/Command.java100
-rw-r--r--src/esieequest/controller/commands/CommandInterface.java25
-rw-r--r--src/esieequest/controller/commands/DoCommand.java35
-rw-r--r--src/esieequest/controller/commands/DropCommand.java41
-rw-r--r--src/esieequest/controller/commands/ForwardCommand.java24
-rw-r--r--src/esieequest/controller/commands/GoCommand.java53
-rw-r--r--src/esieequest/controller/commands/HelpCommand.java20
-rw-r--r--src/esieequest/controller/commands/InventoryCommand.java20
-rw-r--r--src/esieequest/controller/commands/LoadCommand.java19
-rw-r--r--src/esieequest/controller/commands/LookCommand.java29
-rw-r--r--src/esieequest/controller/commands/NewCommand.java28
-rw-r--r--src/esieequest/controller/commands/QuitCommand.java22
-rw-r--r--src/esieequest/controller/commands/SaveCommand.java19
-rw-r--r--src/esieequest/controller/commands/SoundCommand.java19
-rw-r--r--src/esieequest/controller/commands/TakeCommand.java52
-rw-r--r--src/esieequest/controller/commands/TalkCommand.java26
-rw-r--r--src/esieequest/controller/commands/TurnCommand.java37
-rw-r--r--src/esieequest/controller/commands/UseCommand.java35
-rw-r--r--src/esieequest/controller/commands/package-info.java4
-rw-r--r--src/esieequest/esieequest.gwt.xml7
-rw-r--r--src/esieequest/model/Game.java332
-rw-r--r--src/esieequest/model/Player.java288
-rw-r--r--src/esieequest/model/Text.java96
-rw-r--r--src/esieequest/model/characters/Character.java36
-rw-r--r--src/esieequest/model/characters/MovingCharacter.java133
-rw-r--r--src/esieequest/model/characters/Sumobot.java (renamed from src/esieequest/model/entities/Sumobot.java)22
-rw-r--r--src/esieequest/model/characters/package-info.java5
-rw-r--r--src/esieequest/model/commands/Command.java62
-rw-r--r--src/esieequest/model/commands/CommandWord.java12
-rw-r--r--src/esieequest/model/commands/package-info.java5
-rw-r--r--src/esieequest/model/doors/Door.java (renamed from src/esieequest/model/map/Door.java)21
-rw-r--r--src/esieequest/model/doors/HiddenDoor.java (renamed from src/esieequest/model/map/HiddenDoor.java)4
-rw-r--r--src/esieequest/model/doors/LockedDoor.java71
-rw-r--r--src/esieequest/model/doors/TransporterDoor.java54
-rw-r--r--src/esieequest/model/doors/TrapDoor.java (renamed from src/esieequest/model/map/TrapDoor.java)12
-rw-r--r--src/esieequest/model/doors/package-info.java4
-rw-r--r--src/esieequest/model/entities/Character.java25
-rw-r--r--src/esieequest/model/entities/MovingCharacter.java33
-rw-r--r--src/esieequest/model/entities/Player.java125
-rw-r--r--src/esieequest/model/entities/package-info.java5
-rw-r--r--src/esieequest/model/items/Beamer.java30
-rw-r--r--src/esieequest/model/items/Inventory.java125
-rw-r--r--src/esieequest/model/items/Item.java28
-rw-r--r--src/esieequest/model/map/Direction.java79
-rw-r--r--src/esieequest/model/map/LockedDoor.java55
-rw-r--r--src/esieequest/model/map/Orientation.java17
-rw-r--r--src/esieequest/model/map/Room.java279
-rw-r--r--src/esieequest/model/map/Side.java109
-rw-r--r--src/esieequest/model/map/TransporterDoor.java36
-rw-r--r--src/esieequest/view/app/UserInterface.java25
-rw-r--r--src/esieequest/view/text/TextInterface.java2
-rw-r--r--src/esieequest/view/web/WebInterface.java19
64 files changed, 2110 insertions, 1345 deletions
diff --git a/.classpath b/.classpath
index 8836eed..9697427 100644
--- a/.classpath
+++ b/.classpath
@@ -4,5 +4,7 @@
4 <classpathentry kind="src" path="res"/> 4 <classpathentry kind="src" path="res"/>
5 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 5 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
6 <classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/> 6 <classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
7 <classpathentry kind="lib" path="lib/guava-16.0.1.jar"/>
8 <classpathentry kind="lib" path="lib/guava-gwt-16.0.1.jar"/>
7 <classpathentry kind="output" path="war/WEB-INF/classes"/> 9 <classpathentry kind="output" path="war/WEB-INF/classes"/>
8</classpath> 10</classpath>
diff --git a/lib/guava-16.0.1.jar b/lib/guava-16.0.1.jar
new file mode 100644
index 0000000..2c8127d
--- /dev/null
+++ b/lib/guava-16.0.1.jar
Binary files differ
diff --git a/lib/guava-gwt-16.0.1.jar b/lib/guava-gwt-16.0.1.jar
new file mode 100644
index 0000000..d49ada7
--- /dev/null
+++ b/lib/guava-gwt-16.0.1.jar
Binary files differ
diff --git a/src/esieequest/Main.java b/src/esieequest/Main.java
index 362af9c..4759a6e 100755
--- a/src/esieequest/Main.java
+++ b/src/esieequest/Main.java
@@ -47,7 +47,7 @@ public class Main extends JApplet {
47 */ 47 */
48 public static void main(final String[] args) { 48 public static void main(final String[] args) {
49 final List<String> arguments = Arrays.asList(args); 49 final List<String> arguments = Arrays.asList(args);
50 final Game game = new Game(); 50 Game game;
51 View view; 51 View view;
52 52
53 if (arguments.contains("--file")) { 53 if (arguments.contains("--file")) {
@@ -63,7 +63,9 @@ public class Main extends JApplet {
63 } 63 }
64 64
65 if (arguments.contains("--challenge")) { 65 if (arguments.contains("--challenge")) {
66 game.getPlayer().setMaxNbSteps(50); 66 game = new Game(50);
67 } else {
68 game = new Game();
67 } 69 }
68 70
69 new GameEngine(game, view); 71 new GameEngine(game, view);
diff --git a/src/esieequest/controller/GameEngine.java b/src/esieequest/controller/GameEngine.java
index c09967b..df3d34a 100644
--- a/src/esieequest/controller/GameEngine.java
+++ b/src/esieequest/controller/GameEngine.java
@@ -1,6 +1,9 @@
1package esieequest.controller; 1package esieequest.controller;
2 2
3import esieequest.controller.commands.Command;
3import esieequest.model.Game; 4import esieequest.model.Game;
5import esieequest.model.Text;
6import esieequest.model.characters.MovingCharacter;
4import esieequest.view.View; 7import esieequest.view.View;
5 8
6/** 9/**
@@ -14,8 +17,6 @@ public class GameEngine {
14 private final Game game; 17 private final Game game;
15 private final View view; 18 private final View view;
16 19
17 private final Interpreter interpreter;
18
19 /** 20 /**
20 * Instantiates a game engine with the given model and view. 21 * Instantiates a game engine with the given model and view.
21 * 22 *
@@ -30,19 +31,35 @@ public class GameEngine {
30 31
31 this.view.setController(this); 32 this.view.setController(this);
32 33
33 this.interpreter = new Interpreter(this.game, this.view);
34
35 this.view.show(); 34 this.view.show();
36 } 35 }
37 36
38 /** 37 /**
39 * Interprets a command (forward it to the interpreter). 38 * Interprets a command.
40 * 39 *
41 * @param commandString 40 * @param commandString
42 * the command string 41 * the command String
42 */
43 public void interpret(final String inputString) {
44 final Input input = new Input(inputString);
45
46 final Command command = input.getCommand();
47 if (command == null) {
48 this.view.echo(Text.UNKNOWN_COMMAND.getText());
49 return;
50 }
51
52 final String argument = input.getArgument();
53
54 this.executeRoutines();
55 command.execute(argument, this.game, this.view);
56 }
57
58 /**
59 * Actions executed every time a Command is entered.
43 */ 60 */
44 public void interpret(final String command) { 61 private void executeRoutines() {
45 this.interpreter.interpret(command); 62 MovingCharacter.moveAll();
46 } 63 }
47 64
48} 65}
diff --git a/src/esieequest/controller/Input.java b/src/esieequest/controller/Input.java
new file mode 100644
index 0000000..4b4ada5
--- /dev/null
+++ b/src/esieequest/controller/Input.java
@@ -0,0 +1,59 @@
1package esieequest.controller;
2
3import esieequest.controller.commands.Command;
4