diff options
Diffstat (limited to 'src')
61 files changed, 2108 insertions, 1345 deletions
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 @@ | |||
1 | package esieequest.controller; | 1 | package esieequest.controller; |
2 | 2 | ||
3 | import esieequest.controller.commands.Command; | ||
3 | import esieequest.model.Game; | 4 | import esieequest.model.Game; |
5 | import esieequest.model.Text; | ||
6 | import esieequest.model.characters.MovingCharacter; | ||
4 | import esieequest.view.View; | 7 | import 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 @@ | |||
1 | package esieequest.controller; | ||
2 | |||
3 | import esieequest.controller.commands.Command; | ||
4 | |||
5 | /** | ||
6 | * An user textual input. | ||
7 | * | ||
8 | * @author Pacien TRAN-GIRARD | ||
9 | */ | ||
10 | public class Input { | ||
11 | |||
12 | private Command command; | ||
13 | private final String argument; | ||
14 | |||
15 | /** | ||