From 2ec11f60ad89c624c4e84bf4aaf743542c2da35a Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 23 Feb 2014 22:07:22 +0100 Subject: Clean and update comments --- src/esieequest/CommandWords.java | 25 +++++++++++-------------- src/esieequest/Parser.java | 35 +++++++++++++++-------------------- 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/src/esieequest/CommandWords.java b/src/esieequest/CommandWords.java index 3d8855d..de1d132 100644 --- a/src/esieequest/CommandWords.java +++ b/src/esieequest/CommandWords.java @@ -1,25 +1,23 @@ package esieequest; /** - * This class is part of the "World of Zuul" application. "World of Zuul" is a - * very simple, text based adventure game. - * * This class holds an enumeration table of all command words known to the game. - * It is used to recognise commands as they are typed in. + * It is used to recognize commands as they are typed in. + * + * @author Pacien TRAN-GIRARD + * @author Benoit LUBRANO DI SBARAGLIONE * - * @author Michael Kolling and David J. Barnes + D.Bureau - * @version 2008.03.30 + 2013.09.15 + * @version February 2014 */ public class CommandWords { - // a constant array that holds all valid command words private static final String[] sValidCommands = { "go", "quit", "help", "look", "eat" }; /** - * Constructor - initialise the command words. + * Constructor - initialize the command words. */ public CommandWords() { - // nothing to do at the moment... - } // CommandWords() + + } /** * Check whether a given String is a valid command word. @@ -30,8 +28,7 @@ public class CommandWords { for (int i = 0; i < sValidCommands.length; i++) { if (sValidCommands[i].equals(pString)) return true; - } // for - // if we get here, the string was not found in the commands + } return false; - } // isCommand() -} // CommandWords + } +} diff --git a/src/esieequest/Parser.java b/src/esieequest/Parser.java index 4c09013..08f2bca 100644 --- a/src/esieequest/Parser.java +++ b/src/esieequest/Parser.java @@ -3,9 +3,6 @@ package esieequest; import java.util.Scanner; /** - * This class is part of the "World of Zuul" application. "World of Zuul" is a - * very simple, text based adventure game. - * * This parser reads user input and tries to interpret it as an "Adventure" * command. Every time it is called it reads a line from the terminal and tries * to interpret the line as a two word command. It returns the command as an @@ -15,12 +12,14 @@ import java.util.Scanner; * known commands, and if the input is not one of the known commands, it returns * a command object that is marked as an unknown command. * - * @author Michael Kolling and David J. Barnes + D.Bureau - * @version 2008.03.30 + 2013.09.15 + * @author Pacien TRAN-GIRARD + * @author Benoit LUBRANO DI SBARAGLIONE + * + * @version February 2014 */ public class Parser { - private CommandWords aValidCommands; // holds all valid command words - private Scanner aReader; // source of command input + private CommandWords aValidCommands; + private Scanner aReader; /** * Create a parser to read from the terminal window. @@ -28,36 +27,32 @@ public class Parser { public Parser() { this.aValidCommands = new CommandWords(); this.aReader = new Scanner(System.in); - } // Parser() + } /** * @return The next command from the user. */ public Command getCommand() { - String vInputLine; // will hold the full input line + String vInputLine; String vWord1 = null; String vWord2 = null; - System.out.print("> "); // print prompt + System.out.print("> "); vInputLine = this.aReader.nextLine(); - // Find up to two words on the line. Scanner vTokenizer = new Scanner(vInputLine); if (vTokenizer.hasNext()) { - vWord1 = vTokenizer.next(); // get first word + vWord1 = vTokenizer.next(); if (vTokenizer.hasNext()) { - vWord2 = vTokenizer.next(); // get second word - // note: we just ignore the rest of the input line. - } // if - } // if + vWord2 = vTokenizer.next(); + } + } - // Now check whether this word is known. If so, create a command - // with it. If not, create a "null" command (for unknown command). if (this.aValidCommands.isCommand(vWord1)) { return new Command(vWord1, vWord2); } else { return new Command(null, null); } - } // getCommand() -} // Parser + } +} -- cgit v1.2.3 From 98ee109b4a3e61b879d07e818bb426d192b4422e Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 23 Feb 2014 22:08:32 +0100 Subject: Add missing "this" --- src/esieequest/Game.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/esieequest/Game.java b/src/esieequest/Game.java index 350fa15..49ff765 100644 --- a/src/esieequest/Game.java +++ b/src/esieequest/Game.java @@ -223,7 +223,7 @@ public class Game { } private void look() { - System.out.println(aCurrentRoom.getLongDescription()); + System.out.println(this.aCurrentRoom.getLongDescription()); } private void eat() { -- cgit v1.2.3 From 79d33230b556943c1067871e422ed50fd9afb111 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 23 Feb 2014 22:13:07 +0100 Subject: Implement commands listing --- src/esieequest/CommandWords.java | 10 ++++++++++ src/esieequest/Game.java | 2 +- src/esieequest/Parser.java | 7 +++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/esieequest/CommandWords.java b/src/esieequest/CommandWords.java index de1d132..a0718e3 100644 --- a/src/esieequest/CommandWords.java +++ b/src/esieequest/CommandWords.java @@ -31,4 +31,14 @@ public class CommandWords { } return false; } + + /** + * Print all valid commands to System.out. + */ + public void showAll() { + for (String vCommand : this.sValidCommands) { + System.out.print(vCommand + " "); + } + System.out.println(); + } } diff --git a/src/esieequest/Game.java b/src/esieequest/Game.java index 49ff765..ece1bcc 100644 --- a/src/esieequest/Game.java +++ b/src/esieequest/Game.java @@ -219,7 +219,7 @@ public class Game { System.out.println("You wander around at the university."); System.out.println(""); System.out.println("Your command words are:"); - System.out.println(" go quit help"); + this.aParser.showCommands(); } private void look() { diff --git a/src/esieequest/Parser.java b/src/esieequest/Parser.java index 08f2bca..cc3ff11 100644 --- a/src/esieequest/Parser.java +++ b/src/esieequest/Parser.java @@ -55,4 +55,11 @@ public class Parser { return new Command(null, null); } } + + /** + * Print out a list of valid command words. + */ + public void showCommands() { + this.aValidCommands.showAll(); + } } -- cgit v1.2.3 From 3ecc5150121965e1b6f4bbf807d60d5f6694dd1f Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 23 Feb 2014 22:16:25 +0100 Subject: Update report --- report/progression.tex | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/report/progression.tex b/report/progression.tex index 2f25aea..c4f6c52 100644 --- a/report/progression.tex +++ b/report/progression.tex @@ -73,8 +73,14 @@ The eat command has been added with the commit 40b9b4816. \subsection{showAll, showCommands} +This modifications are part of the commit 79d33230b. + \subsection{Adding commands} +Adding new commands would not require modifying the printHelp() method anymore. +However, adding new commands and related functions would still require editing +the Game class and its processCommand() method. + \subsection{getCommandList} \subsection{Comparison with reference} -- cgit v1.2.3 From 590a932e53423d9b1cd92344ee0187972b8ed961 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 23 Feb 2014 22:26:57 +0100 Subject: Remove useless printLocationInfo() --- src/esieequest/Game.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/esieequest/Game.java b/src/esieequest/Game.java index ece1bcc..165724a 100644 --- a/src/esieequest/Game.java +++ b/src/esieequest/Game.java @@ -21,8 +21,7 @@ public class Game { */ public Game() { this.createRooms(); - this.printWelcome(); - this.printLocationInfo(); + this.aParser = new Parser(); this.play(); } @@ -30,7 +29,7 @@ public class Game { * Main play routine. Loops until end of play. */ private void play() { - aParser = new Parser(); + this.printWelcome(); boolean vFinished = false; while (!vFinished) { Command vCommand = this.aParser.getCommand(); @@ -193,10 +192,6 @@ public class Game { } this.aCurrentRoom = vNextRoom; - this.printLocationInfo(); - } - - private void printLocationInfo() { System.out.println(this.aCurrentRoom.getLongDescription()); } @@ -208,6 +203,7 @@ public class Game { System.out.println("ESIEEquest is a new, incredibly surprising adventure game."); System.out.println("Type 'help' if you need help."); System.out.println(""); + System.out.println(this.aCurrentRoom.getLongDescription()); } /** -- cgit v1.2.3 From 990c537953dc9b8a7e5236a9c23e8978ea746348 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 23 Feb 2014 22:27:15 +0100 Subject: Initialize local variable --- src/esieequest/Parser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/esieequest/Parser.java b/src/esieequest/Parser.java index cc3ff11..b8f5c94 100644 --- a/src/esieequest/Parser.java +++ b/src/esieequest/Parser.java @@ -33,7 +33,7 @@ public class Parser { * @return The next command from the user. */ public Command getCommand() { - String vInputLine; + String vInputLine = null; String vWord1 = null; String vWord2 = null; -- cgit v1.2.3 From f84606424a6d14d9a125aca48de5d5b7934eaa7a Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 23 Feb 2014 22:27:36 +0100 Subject: Add description getter --- src/esieequest/Room.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/esieequest/Room.java b/src/esieequest/Room.java index 9bfb40b..0ba71d9 100644 --- a/src/esieequest/Room.java +++ b/src/esieequest/Room.java @@ -7,9 +7,9 @@ import java.util.Set; * A room. * * A "Room" represents one location in the scenery of the game. It is connected - * to other rooms via exits. The exits are labeled north, east, south, west. - * For each direction, the room stores a reference to the neighboring room, or - * null if there is no exit in that direction. + * to other rooms via exits. The exits are labeled north, east, south, west. For + * each direction, the room stores a reference to the neighboring room, or null + * if there is no exit in that direction. * * @author Pacien TRAN-GIRARD * @author Benoit LUBRANO DI SBARAGLIONE @@ -34,6 +34,14 @@ public class Room { } + /** + * Return the description of the room (the one that was defined in the + * constructor). + */ + public String getShortDescription() { + return this.aDescription; + } + /** * Return a long description of this room, of the form: * -- cgit v1.2.3 From 0c5793abf9cf5efe97eed6f778e18171198ff857 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 23 Feb 2014 22:31:31 +0100 Subject: Use iterator --- src/esieequest/Room.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/esieequest/Room.java b/src/esieequest/Room.java index 0ba71d9..4626490 100644 --- a/src/esieequest/Room.java +++ b/src/esieequest/Room.java @@ -1,6 +1,7 @@ package esieequest; import java.util.HashMap; +import java.util.Iterator; import java.util.Set; /** @@ -85,9 +86,9 @@ public class Room { */ public String getExitString() { String vExitString = "Available exits:"; - Set keys = this.aExits.keySet(); - for (String exit : keys) { - vExitString += " " + exit; + Set vKeys = this.aExits.keySet(); + for (Iterator vIter = vKeys.iterator(); vIter.hasNext();) { + vExitString += " " + vIter.next(); } vExitString += "."; return vExitString; -- cgit v1.2.3 From 5de55c8b8417b22a72ff0c59687a7c0c2eaf8a6e Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 23 Feb 2014 22:40:43 +0100 Subject: Update report --- report/progression.tex | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/report/progression.tex b/report/progression.tex index c4f6c52..36b9f19 100644 --- a/report/progression.tex +++ b/report/progression.tex @@ -85,6 +85,16 @@ the Game class and its processCommand() method. \subsection{Comparison with reference} +The printLocationInfo() method, used only twice, has been trimmed by the commit +590a932e5 and has been replaced by a call to the getLongDescription() method of +the Room class. + +A missing getter for the Room description has been added as part of the commit +f84606424. + +The loop building the command list String has been modified to use an Iterator +with the commit 0c5793abf. + \subsection{StringBuilder} \subsection{Room objects} -- cgit v1.2.3 From 5f1d0ada248764beda05dee2695bab802eeadcd6 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 23 Feb 2014 22:44:26 +0100 Subject: Change command list printing --- src/esieequest/CommandWords.java | 7 ++++--- src/esieequest/Game.java | 2 +- src/esieequest/Parser.java | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/esieequest/CommandWords.java b/src/esieequest/CommandWords.java index a0718e3..c942043 100644 --- a/src/esieequest/CommandWords.java +++ b/src/esieequest/CommandWords.java @@ -35,10 +35,11 @@ public class CommandWords { /** * Print all valid commands to System.out. */ - public void showAll() { + public String getCommandList() { + String vCommands = ""; for (String vCommand : this.sValidCommands) { - System.out.print(vCommand + " "); + vCommands += " " + vCommand; } - System.out.println(); + return vCommands; } } diff --git a/src/esieequest/Game.java b/src/esieequest/Game.java index 165724a..cae7559 100644 --- a/src/esieequest/Game.java +++ b/src/esieequest/Game.java @@ -215,7 +215,7 @@ public class Game { System.out.println("You wander around at the university."); System.out.println(""); System.out.println("Your command words are:"); - this.aParser.showCommands(); + System.out.println(this.aParser.showCommands()); } private void look() { diff --git a/src/esieequest/Parser.java b/src/esieequest/Parser.java index b8f5c94..d270f1e 100644 --- a/src/esieequest/Parser.java +++ b/src/esieequest/Parser.java @@ -59,7 +59,7 @@ public class Parser { /** * Print out a list of valid command words. */ - public void showCommands() { - this.aValidCommands.showAll(); + public String showCommands() { + return this.aValidCommands.getCommandList(); } } -- cgit v1.2.3 From 6a11706b099d1dc2a18b139bfb256b50bddc22ff Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 23 Feb 2014 22:48:01 +0100 Subject: Update report --- report/progression.tex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/report/progression.tex b/report/progression.tex index 36b9f19..08efc02 100644 --- a/report/progression.tex +++ b/report/progression.tex @@ -83,6 +83,10 @@ the Game class and its processCommand() method. \subsection{getCommandList} +The command list is not printed in the CommandWords class anymore. Instead, this +class returns a String, forwarded by the Parser class, that is then printed in +the Game class, thanks to commit 5f1d0ada2. + \subsection{Comparison with reference} The printLocationInfo() method, used only twice, has been trimmed by the commit -- cgit v1.2.3 From ee5ec33aa48b334933b47079634e34cdd2f3b6c2 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 23 Feb 2014 23:01:40 +0100 Subject: Use StringBuilder --- src/esieequest/CommandWords.java | 8 ++++---- src/esieequest/Room.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/esieequest/CommandWords.java b/src/esieequest/CommandWords.java index c942043..e2d50f5 100644 --- a/src/esieequest/CommandWords.java +++ b/src/esieequest/CommandWords.java @@ -36,10 +36,10 @@ public class CommandWords { * Print all valid commands to System.out. */ public String getCommandList() { - String vCommands = ""; - for (String vCommand : this.sValidCommands) { - vCommands += " " + vCommand; + StringBuilder vStrBuilder = new StringBuilder(); + for (String vCommand : sValidCommands) { + vStrBuilder.append(" ").append(vCommand); } - return vCommands; + return vStrBuilder.toString(); } } diff --git a/src/esieequest/Room.java b/src/esieequest/Room.java index 4626490..6d05b58 100644 --- a/src/esieequest/Room.java +++ b/src/esieequest/Room.java @@ -85,13 +85,13 @@ public class Room { * @return A description of the available exits. */ public String getExitString() { - String vExitString = "Available exits:"; + StringBuilder vStrBuilder = new StringBuilder("Available exits:"); Set vKeys = this.aExits.keySet(); for (Iterator vIter = vKeys.iterator(); vIter.hasNext();) { - vExitString += " " + vIter.next(); + vStrBuilder.append(" ").append(vIter.next()); } - vExitString += "."; - return vExitString; + vStrBuilder.append("."); + return vStrBuilder.toString(); } } -- cgit v1.2.3 From b330f6389b768d238fd4587800dca707becc661b Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 23 Feb 2014 23:04:34 +0100 Subject: Update report --- report/progression.tex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/report/progression.tex b/report/progression.tex index 08efc02..ae24a63 100644 --- a/report/progression.tex +++ b/report/progression.tex @@ -101,6 +101,10 @@ with the commit 0c5793abf. \subsection{StringBuilder} +The command list and the exit list are now created using a StringBuilder since +commit ee5ec33aa. This avoids the creation of a new String object at each +concatenation, and thus allows better performances. + \subsection{Room objects} -- cgit v1.2.3 From f64f1ffb0057f0096dcd9d3d8c0349545f00d246 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 23 Feb 2014 23:30:50 +0100 Subject: Use an HashMap to store Rooms --- src/esieequest/Game.java | 230 ++++++++++++++++++++++++----------------------- 1 file changed, 117 insertions(+), 113 deletions(-) diff --git a/src/esieequest/Game.java b/src/esieequest/Game.java index cae7559..43db8f7 100644 --- a/src/esieequest/Game.java +++ b/src/esieequest/Game.java @@ -1,5 +1,7 @@ package esieequest; +import java.util.HashMap; + /** * The game engine. * @@ -13,6 +15,7 @@ package esieequest; * @version February 2014 */ public class Game { + private HashMap aRooms; private Room aCurrentRoom; private Parser aParser; @@ -20,6 +23,7 @@ public class Game { * Create the game and initialize its internal map. */ public Game() { + this.aRooms = new HashMap(); this.createRooms(); this.aParser = new Parser(); this.play(); @@ -44,134 +48,134 @@ public class Game { */ private void createRooms() { // create rooms - Room vAmphitheaterSeat = new Room("in the amphitheater"); - Room vAmphitheaterStage = new Room("on the amphitheater stage"); + this.aRooms.put("AmphitheaterSeat", new Room("in the amphitheater")); + this.aRooms.put("AmphitheaterStage", new Room("on the amphitheater stage")); - Room vCafeteriaStreet = new Room("in the main corridor, in front of the cafeteria"); - Room vCafeteria = new Room("at the cafeteria"); + this.aRooms.put("CafeteriaStreet", new Room("in the main corridor, in front of the cafeteria")); + this.aRooms.put("Cafeteria", new Room("at the cafeteria")); - Room vEsieespaceStreet = new Room("in the main corridor, in front of the ESIEEspace HQ"); - Room vEsieespaceFront = new Room("in front of the ESIEEspace HQ"); - Room vEsieespaceEntrance = new Room("at the ESIEEspace HQ entrance"); - Room vEsieespace = new Room("in the ESIEEspace HQ"); + this.aRooms.put("EsieespaceStreet", new Room("in the main corridor, in front of the ESIEEspace HQ")); + this.aRooms.put("EsieespaceFront", new Room("in front of the ESIEEspace HQ")); + this.aRooms.put("EsieespaceEntrance", new Room("at the ESIEEspace HQ entrance")); + this.aRooms.put("Esieespace", new Room("in the ESIEEspace HQ")); - Room vClubnixStreet = new Room("in the main corridor, in front of the Club*Nix"); - Room vClubnixFront = new Room("in front of the Club*Nix"); - Room vClubnixEntrance = new Room("at the Club*Nix entrance"); - Room vClubnix = new Room("in the Club*Nix"); + this.aRooms.put("ClubnixStreet", new Room("in the main corridor, in front of the Club*Nix")); + this.aRooms.put("ClubnixFront", new Room("in front of the Club*Nix")); + this.aRooms.put("ClubnixEntrance", new Room("at the Club*Nix entrance")); + this.aRooms.put("Clubnix", new Room("in the Club*Nix")); - Room vEntranceStreet = new Room("in the main corridor, at the reception"); - Room vEntranceStairs = new Room("on the main entrance stairs"); - Room vEntranceRoundabout = new Room("on the roundabout"); + this.aRooms.put("EntranceStreet", new Room("in the main corridor, at the reception")); + this.aRooms.put("EntranceStairs", new Room("on the main entrance stairs")); + this.aRooms.put("EntranceRoundabout", new Room("on the roundabout")); - Room vWingStreet = new Room("in font of wing #3"); - Room vWingCorridorOne = new Room("in the corridor in wing #3, on the ground floor"); - Room vWingStairsOne = new Room("in the stairwell on the ground floor"); - Room vWingStairsTwo = new Room("in the stairwell on the first floor"); - Room vWingCorridorTwo = new Room("in the corridor in wind #3, on the first floor"); - Room vWingCorridorTwoOffice = new Room("in front of the office #3254"); - Room vWingOffice = new Room("in the office #3254"); + this.aRooms.put("WingStreet", new Room("in font of wing #3")); + this.aRooms.put("WingCorridorOne", new Room("in the corridor in wing #3, on the ground floor")); + this.aRooms.put("WingStairsOne", new Room("in the stairwell on the ground floor")); + this.aRooms.put("WingStairsTwo", new Room("in the stairwell on the first floor")); + this.aRooms.put("WingCorridorTwo", new Room("in the corridor in wind #3, on the first floor")); + this.aRooms.put("WingCorridorTwoOffice", new Room("in front of the office #3254")); + this.aRooms.put("WingOffice", new Room("in the office #3254")); - Room vOffscriptEat = new Room("somewhere implementing hunger"); - Room vOffscriptEatPantry = new Room("in the pantry"); - Room vOffscriptTake = new Room("somewhere implementing weight"); - Room vOffscriptTakeStorageroom = new Room("in a storage room"); - Room vOffscriptTimeout = new Room("somewhere implementing time"); - Room vOffscriptTimeoutCountdownroom = new Room("in a dangerous room"); - Room vOffscriptTrapdoor = new Room("somewhere implementing a trap"); - Room vOffscriptTrapdoorDeadend = new Room("trapped"); - Room vOffscriptBeamer = new Room("somewhere implementing teleportation"); - Room vOffscriptBeamerAnchor = new Room("on a checkpoint"); - Room vOffscriptLock = new Room("somewhere implementing a doorlock"); - Room vOffscriptLockLockedroom = new Room("in a locked room that is not anymore"); - Room vOffscriptAlea = new Room("somewhere implementing alea"); - Room vOffscriptAleaRoomrandomizer = new Room("in a weird room that will transport you somewhere else"); - Room vOffscriptMovingcharacter = new Room("somewhere implementing a moving character"); - Room vOffscriptMovingcharacterMo = new Room("in M-O's room"); + this.aRooms.put("OffscriptEat", new Room("somewhere implementing hunger")); + this.aRooms.put("OffscriptEatPantry", new Room("in the pantry")); + this.aRooms.put("OffscriptTake", new Room("somewhere implementing weight")); + this.aRooms.put("OffscriptTakeStorageroom", new Room("in a storage room")); + this.aRooms.put("OffscriptTimeout", new Room("somewhere implementing time")); + this.aRooms.put("OffscriptTimeoutCountdownroom", new Room("in a dangerous room")); + this.aRooms.put("OffscriptTrapdoor", new Room("somewhere implementing a trap")); + this.aRooms.put("OffscriptTrapdoorDeadend", new Room("trapped")); + this.aRooms.put("OffscriptBeamer", new Room("somewhere implementing teleportation")); + this.aRooms.put("OffscriptBeamerAnchor", new Room("on a checkpoint")); + this.aRooms.put("OffscriptLock", new Room("somewhere implementing a doorlock")); + this.aRooms.put("OffscriptLockLockedroom", new Room("in a locked room that is not anymore")); + this.aRooms.put("OffscriptAlea", new Room("somewhere implementing alea")); + this.aRooms.put("OffscriptAleaRoomrandomizer", new Room("in a weird room that will transport you somewhere else")); + this.aRooms.put("OffscriptMovingcharacter", new Room("somewhere implementing a moving character")); + this.aRooms.put("OffscriptMovingcharacterMo", new Room("in M-O's room")); - // connect rooms (N, W, S, E) - vAmphitheaterSeat.setExit("north", vAmphitheaterStage); - vAmphitheaterStage.setExit("west", vCafeteria); + // connect rooms + this.aRooms.get("AmphitheaterSeat").setExit("north", this.aRooms.get("AmphitheaterStage")); + this.aRooms.get("AmphitheaterStage").setExit("west", this.aRooms.get("Cafeteria")); - vCafeteriaStreet.setExit("south", vCafeteria); - vCafeteriaStreet.setExit("east", vEsieespaceStreet); - vCafeteria.setExit("north", vCafeteriaStreet); - vCafeteria.setExit("east", vAmphitheaterStage); + this.aRooms.get("CafeteriaStreet").setExit("south", this.aRooms.get("Cafeteria")); + this.aRooms.get("CafeteriaStreet").setExit("east", this.aRooms.get("EsieespaceStreet")); + this.aRooms.get("Cafeteria").setExit("north", this.aRooms.get("CafeteriaStreet")); + this.aRooms.get("Cafeteria").setExit("east", this.aRooms.get("AmphitheaterStage")); - vEsieespaceStreet.setExit("west", vCafeteria); - vEsieespaceStreet.setExit("south", vEsieespaceFront); - vEsieespaceStreet.setExit("east", vEntranceStreet); - vEsieespaceFront.setExit("north", vEsieespaceStreet); - vEsieespaceFront.setExit("east", vEsieespaceEntrance); - vEsieespaceEntrance.setExit("north", vEsieespace); - vEsieespaceEntrance.setExit("west", vEsieespaceFront); - vEsieespace.setExit("south", vEsieespaceEntrance); + this.aRooms.get("EsieespaceStreet").setExit("west", this.aRooms.get("Cafeteria")); + this.aRooms.get("EsieespaceStreet").setExit("south", this.aRooms.get("EsieespaceFront")); + this.aRooms.get("EsieespaceStreet").setExit("east", this.aRooms.get("EntranceStreet")); + this.aRooms.get("EsieespaceFront").setExit("north", this.aRooms.get("EsieespaceStreet")); + this.aRooms.get("EsieespaceFront").setExit("east", this.aRooms.get("EsieespaceEntrance")); + this.aRooms.get("EsieespaceEntrance").setExit("north", this.aRooms.get("Esieespace")); + this.aRooms.get("EsieespaceEntrance").setExit("west", this.aRooms.get("EsieespaceFront")); + this.aRooms.get("Esieespace").setExit("south", this.aRooms.get("EsieespaceEntrance")); - vClubnixStreet.setExit("west", vWingStreet); - vClubnixStreet.setExit("south", vClubnixFront); - vClubnixFront.setExit("north", vClubnixStreet); - vClubnixFront.setExit("east", vClubnixEntrance); - vClubnixEntrance.setExit("north", vClubnix); - vClubnixEntrance.setExit("west", vClubnixFront); - vClubnix.setExit("south", vClubnixEntrance); + this.aRooms.get("ClubnixStreet").setExit("west", this.aRooms.get("WingStreet")); + this.aRooms.get("ClubnixStreet").setExit("south", this.aRooms.get("ClubnixFront")); + this.aRooms.get("ClubnixFront").setExit("north", this.aRooms.get("ClubnixStreet")); + this.aRooms.get("ClubnixFront").setExit("east", this.aRooms.get("ClubnixEntrance")); + this.aRooms.get("ClubnixEntrance").setExit("north", this.aRooms.get("Clubnix")); + this.aRooms.get("ClubnixEntrance").setExit("west", this.aRooms.get("ClubnixFront")); + this.aRooms.get("Clubnix").setExit("south", this.aRooms.get("ClubnixEntrance")); - vEntranceStreet.setExit("west", vEsieespaceStreet); - vEntranceStreet.setExit("south", vEntranceStairs); - vEntranceStreet.setExit("east", vWingStreet); - vEntranceStairs.setExit("north", vEntranceStreet); - vEntranceStairs.setExit("south", vEntranceRoundabout); - vEntranceRoundabout.setExit("north", vEntranceStairs); + this.aRooms.get("EntranceStreet").setExit("west", this.aRooms.get("EsieespaceStreet")); + this.aRooms.get("EntranceStreet").setExit("south", this.aRooms.get("EntranceStairs")); + this.aRooms.get("EntranceStreet").setExit("east", this.aRooms.get("WingStreet")); + this.aRooms.get("EntranceStairs").setExit("north", this.aRooms.get("EntranceStreet")); + this.aRooms.get("EntranceStairs").setExit("south", this.aRooms.get("EntranceRoundabout")); + this.aRooms.get("EntranceRoundabout").setExit("north", this.aRooms.get("EntranceStairs")); - vWingStreet.setExit("north", vWingCorridorOne); - vWingStreet.setExit("west", vEntranceStreet); - vWingStreet.setExit("east", vClubnixStreet); - vWingCorridorOne.setExit("west", vWingStairsOne); - vWingCorridorOne.setExit("south", vWingStreet); - vWingCorridorOne.setExit("east", vOffscriptEat); - vWingStairsOne.setExit("south", vWingStairsTwo); - vWingStairsOne.setExit("up", vWingStairsTwo); - vWingStairsOne.setExit("east", vWingCorridorOne); - vWingStairsTwo.setExit("south", vWingStairsOne); - vWingStairsTwo.setExit("down", vWingStairsOne); - vWingStairsTwo.setExit("east", vWingCorridorTwo); - vWingCorridorTwo.setExit("north", vWingCorridorTwoOffice); - vWingCorridorTwoOffice.setExit("south", vWingCorridorTwo); - vWingCorridorTwoOffice.setExit("east", vWingOffice); - vWingOffice.setExit("west", vWingCorridorTwoOffice); + this.aRooms.get("WingStreet").setExit("north", this.aRooms.get("WingCorridorOne")); + this.aRooms.get("WingStreet").setExit("west", this.aRooms.get("EntranceStreet")); + this.aRooms.get("WingStreet").setExit("east", this.aRooms.get("ClubnixStreet")); + this.aRooms.get("WingCorridorOne").setExit("west", this.aRooms.get("WingStairsOne")); + this.aRooms.get("WingCorridorOne").setExit("south", this.aRooms.get("WingStreet")); + this.aRooms.get("WingCorridorOne").setExit("east", this.aRooms.get("OffscriptEat")); + this.aRooms.get("WingStairsOne").setExit("south", this.aRooms.get("WingStairsTwo")); + this.aRooms.get("WingStairsOne").setExit("up", this.aRooms.get("WingStairsTwo")); + this.aRooms.get("WingStairsOne").setExit("east", this.aRooms.get("WingCorridorOne")); + this.aRooms.get("WingStairsTwo").setExit("south", this.aRooms.get("WingStairsOne")); + this.aRooms.get("WingStairsTwo").setExit("down", this.aRooms.get("WingStairsOne")); + this.aRooms.get("WingStairsTwo").setExit("east", this.aRooms.get("WingCorridorTwo")); + this.aRooms.get("WingCorridorTwo").setExit("north", this.aRooms.get("WingCorridorTwoOffice")); + this.aRooms.get("WingCorridorTwoOffice").setExit("south", this.aRooms.get("WingCorridorTwo")); + this.aRooms.get("WingCorridorTwoOffice").setExit("east", this.aRooms.get("WingOffice")); + this.aRooms.get("WingOffice").setExit("west", this.aRooms.get("WingCorridorTwoOffice")); - vOffscriptEat.setExit("north", vOffscriptEatPantry); - vOffscriptEat.setExit("west", vWingCorridorOne); - vOffscriptEat.setExit("east", vOffscriptTake); - vOffscriptEatPantry.setExit("south", vOffscriptEat); - vOffscriptTake.setExit("north", vOffscriptTakeStorageroom); - vOffscriptTake.setExit("west", vOffscriptEat); - vOffscriptTake.setExit("east", vOffscriptTimeout); - vOffscriptTakeStorageroom.setExit("south", vOffscriptTake); - vOffscriptTimeout.setExit("north", vOffscriptTimeoutCountdownroom); - vOffscriptTimeout.setExit("west", vOffscriptTakeStorageroom); - vOffscriptTimeout.setExit("east", vOffscriptTrapdoor); - vOffscriptTimeoutCountdownroom.setExit("south", vOffscriptTimeout); - vOffscriptTrapdoor.setExit("north", vOffscriptTrapdoorDeadend); - vOffscriptTrapdoor.setExit("west", vOffscriptTimeout); - vOffscriptTrapdoor.setExit("east", vOffscriptBeamer); - vOffscriptTrapdoorDeadend.setExit("south", vOffscriptTrapdoor); - vOffscriptBeamer.setExit("north", vOffscriptBeamerAnchor); - vOffscriptBeamer.setExit("west", vOffscriptTrapdoor); - vOffscriptBeamer.setExit("east", vOffscriptLock); - vOffscriptBeamerAnchor.setExit("south", vOffscriptBeamer); - vOffscriptLock.setExit("north", vOffscriptLockLockedroom); - vOffscriptLock.setExit("west", vOffscriptBeamer); - vOffscriptLock.setExit("east", vOffscriptAlea); - vOffscriptLockLockedroom.setExit("south", vOffscriptLock); - vOffscriptAlea.setExit("north", vOffscriptAleaRoomrandomizer); - vOffscriptAlea.setExit("west", vOffscriptLock); - vOffscriptAlea.setExit("east", vOffscriptMovingcharacter); - vOffscriptAleaRoomrandomizer.setExit("south", vOffscriptAlea); - vOffscriptMovingcharacter.setExit("north", vOffscriptMovingcharacterMo); - vOffscriptMovingcharacter.setExit("west", vOffscriptAlea); + this.aRooms.get("OffscriptEat").setExit("north", this.aRooms.get("OffscriptEatPantry")); + this.aRooms.get("OffscriptEat").setExit("west", this.aRooms.get("WingCorridorOne")); + this.aRooms.get("OffscriptEat").setExit("east", this.aRooms.get("OffscriptTake")); + this.aRooms.get("OffscriptEatPantry").setExit("south", this.aRooms.get("OffscriptEat")); + this.aRooms.get("OffscriptTake").setExit("north", this.aRooms.get("OffscriptTakeStorageroom")); + this.aRooms.get("OffscriptTake").setExit("west", this.aRooms.get("OffscriptEat")); + this.aRooms.get("OffscriptTake").setExit("east", this.aRooms.get("OffscriptTimeout")); + this.aRooms.get("OffscriptTakeStorageroom").setExit("south", this.aRooms.get("OffscriptTake")); + this.aRooms.get("OffscriptTimeout").setExit("north", this.aRooms.get("OffscriptTimeoutCountdownroom")); + this.aRooms.get("OffscriptTimeout").setExit("west", this.aRooms.get("OffscriptTakeStorageroom")); + this.aRooms.get("OffscriptTimeout").setExit("east", this.aRooms.get("OffscriptTrapdoor")); + this.aRooms.get("OffscriptTimeoutCountdownroom").setExit("south", this.aRooms.get("OffscriptTimeout")); + this.aRooms.get("OffscriptTrapdoor").setExit("north", this.aRooms.get("OffscriptTrapdoorDeadend")); + this.aRooms.get("OffscriptTrapdoor").setExit("west", this.aRooms.get("OffscriptTimeout")); + this.aRooms.get("OffscriptTrapdoor").setExit("east", this.aRooms.get("OffscriptBeamer")); + this.aRooms.get("OffscriptTrapdoorDeadend").setExit("south", this.aRooms.get("OffscriptTrapdoor")); + this.aRooms.get("OffscriptBeamer").setExit("north", this.aRooms.get("OffscriptBeamerAnchor")); + this.aRooms.get("OffscriptBeamer").setExit("west", this.aRooms.get("OffscriptTrapdoor")); + this.aRooms.get("OffscriptBeamer").setExit("east", this.aRooms.get("OffscriptLock")); + this.aRooms.get("OffscriptBeamerAnchor").setExit("south", this.aRooms.get("OffscriptBeamer")); + this.aRooms.get("OffscriptLock").setExit("north", this.aRooms.get("OffscriptLockLockedroom")); + this.aRooms.get("OffscriptLock").setExit("west", this.aRooms.get("OffscriptBeamer")); + this.aRooms.get("OffscriptLock").setExit("east", this.aRooms.get("OffscriptAlea")); + this.aRooms.get("OffscriptLockLockedroom").setExit("south", this.aRooms.get("OffscriptLock")); + this.aRooms.get("OffscriptAlea").setExit("north", this.aRooms.get("OffscriptAleaRoomrandomizer")); + this.aRooms.get("OffscriptAlea").setExit("west", this.aRooms.get("OffscriptLock")); + this.aRooms.get("OffscriptAlea").setExit("east", this.aRooms.get("OffscriptMovingcharacter")); + this.aRooms.get("OffscriptAleaRoomrandomizer").setExit("south", this.aRooms.get("OffscriptAlea")); + this.aRooms.get("OffscriptMovingcharacter").setExit("north", this.aRooms.get("OffscriptMovingcharacterMo")); + this.aRooms.get("OffscriptMovingcharacter").setExit("west", this.aRooms.get("OffscriptAlea")); // set the starting room - this.aCurrentRoom = vAmphitheaterSeat; + this.aCurrentRoom = this.aRooms.get("AmphitheaterSeat"); } /** -- cgit v1.2.3 From 52595afbd4a0e2e2ed41f680c3b84742bf16b530 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 23 Feb 2014 23:32:23 +0100 Subject: Update report --- report/progression.tex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/report/progression.tex b/report/progression.tex index ae24a63..da5e34e 100644 --- a/report/progression.tex +++ b/report/progression.tex @@ -107,6 +107,8 @@ concatenation, and thus allows better performances. \subsection{Room objects} +Rooms are now stored in an HashMap since commit f64f1ffb0, so they can be +passed to any method in any class. \section{Zuul with images} -- cgit v1.2.3