From f5f6260f41fc16ee9abcae8bb2f26c45d8e29efa Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Wed, 2 Apr 2014 10:17:27 +0200 Subject: Add missing classes --- src/esieequest/controller/GameEngine.java | 1 - src/esieequest/controller/Performer.java | 6 ++--- src/esieequest/model/Game.java | 29 +++++++------------- src/esieequest/model/Quest.java | 22 ++++++++++++++++ src/esieequest/model/Side.java | 5 ++++ src/esieequest/model/command/CommandWord.java | 38 +++++++++++++-------------- src/esieequest/view/text/FileReader.java | 8 +++--- src/esieequest/view/web/WebInterface.ui.xml | 7 ++--- 8 files changed, 67 insertions(+), 49 deletions(-) create mode 100644 src/esieequest/model/Quest.java create mode 100644 src/esieequest/model/Side.java (limited to 'src') 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 { this.game = game; this.view = view; - this.view.setModel(game); this.view.setController(this); 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 { final Room nextRoom = this.game.getRoomExit(direction); if (nextRoom != null) { this.game.goToRoom(nextRoom); - this.echo(this.game.getLocationInfo()); + this.view.updateRoom(this.game.getCurrentRoom()); } else { this.echo(this.game.getNoExitMessage()); } @@ -113,14 +113,14 @@ class Performer { */ public void goBack() { this.game.goToPreviousRoom(); - this.echo(this.game.getLocationInfo()); + this.view.updateRoom(this.game.getCurrentRoom()); } /** * Displays informations about the current place. */ public void look() { - this.echo(this.game.getLocationInfo()); + this.echo(this.game.getCurrentRoom().getInformations()); } /** 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 { private final HashMap rooms; private Room currentRoom; + private final Stack previousRooms; /** @@ -213,6 +214,15 @@ public class Game { } } + /** + * Returns the current room. + * + * @return the current room + */ + public Room getCurrentRoom() { + return this.currentRoom; + } + /** * Returns the current room's exit located in the given direction. * @@ -225,25 +235,6 @@ public class Game { return this.currentRoom.getExit(direction); } - /** - * Returns informations about the current room (description, exits and - * items). - * - * @return the informations about the current room - */ - public String getLocationInfo() { - return this.currentRoom.getInformations(); - } - - /** - * Returns the current room's image name. - * - * @return the current room's image name. - */ - public String getLocationImageName() { - return this.currentRoom.getImageName(); - } - /** * Returns 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 @@ +package esieequest.model; + +public class Quest { + + private String title; + + /** + * @return the title + */ + public String getTitle() { + return this.title; + } + + /** + * @param title + * the title to set + */ + public void setTitle(final String title) { + this.title = title; + } + +} 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 @@ +package esieequest.model; + +public class Side { + +} 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; public enum CommandWord { // @formatter:off - // COMMAND ARGUMENTS ("" = no one ; null = any) - NEW( "new", new String[] { "" }), - LOAD( "load", new String[] { "" }), - SAVE( "save", new String[] { "" }), - SOUND( "sound", new String[] { "" }), - HELP( "help", new String[] { "" }), - QUIT( "quit", new String[] { "" }), - LOOK( "look", new String[] { "" }), - EAT( "eat", new String[] { "" }), - FORWARD( "forward", new String[] { "" }), - BACK( "back", new String[] { "" }), - GO( "go", new String[] { "north", "south", "east", "west", "up", "down" }), - TURN( "turn", new String[] { "left", "right" }), - DO( "do", new String[] { "" }), - TAKE( "take", new String[] { "" }), - TALK( "talk", new String[] { "" }), - INVENTORY( "inventory", new String[] { "" }), - USE( "use", null), - UNKNOWN( "?", new String[] { "" }); + // COMMAND ARGUMENTS ("" = no one ; null = any) + NEW ( "new", new String[] { "" } ), + LOAD ( "load", new String[] { "" } ), + SAVE ( "save", new String[] { "" } ), + SOUND ( "sound", new String[] { "" } ), + HELP ( "help", new String[] { "" } ), + QUIT ( "quit", new String[] { "" } ), + LOOK ( "look", new String[] { "" } ), + EAT ( "eat", new String[] { "" } ), + FORWARD ( "forward", new String[] { "" } ), + BACK ( "back", new String[] { "" } ), + GO ( "go", new String[] { "north", "south", "east", "west", "up", "down" } ), + TURN ( "turn", new String[] { "left", "right" } ), + DO ( "do", new String[] { "" } ), + TAKE ( "take", new String[] { "" } ), + TALK ( "talk", new String[] { "" } ), + INVENTORY ( "inventory", new String[] { "" } ), + USE ( "use", null ), + UNKNOWN ( "?", new String[] { "" } ); // @formatter:on 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; */ public class FileReader extends TextInterface { - private File file; + private final File file; /** * The FileReader initialiser. @@ -30,16 +30,16 @@ public class FileReader extends TextInterface { @Override protected void run() { try { - final Scanner scanner = new Scanner(file); + final Scanner scanner = new Scanner(this.file); while (this.running && scanner.hasNextLine()) { - String line = scanner.nextLine(); + final String line = scanner.nextLine(); System.out.println("> " + line); if (!line.startsWith("//")) { this.gameEngine.interpret(line); } } scanner.close(); - } catch (FileNotFoundException exception) { + } catch (final FileNotFoundException exception) { System.out.println("Error: file not found."); } } diff --git a/src/esieequest/view/web/WebInterface.ui.xml b/src/esieequest/view/web/WebInterface.ui.xml index 4310407..8ded623 100644 --- a/src/esieequest/view/web/WebInterface.ui.xml +++ b/src/esieequest/view/web/WebInterface.ui.xml @@ -11,8 +11,8 @@ - + @@ -39,7 +39,8 @@ ui:field="bottomPanel"> Console - -- cgit v1.2.3