From 2fee72805e1025a298295e6d86de18e48de4b52a Mon Sep 17 00:00:00 2001 From: Benoît LUBRANO DI SBARAGLIONE Date: Wed, 9 Apr 2014 11:26:33 +0200 Subject: Add challenge mode with walk method. --- src/esieequest/Main.java | 4 ++++ src/esieequest/controller/Performer.java | 10 +++++++++ src/esieequest/model/entities/Player.java | 34 +++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/src/esieequest/Main.java b/src/esieequest/Main.java index 59ac568..e8cff08 100755 --- a/src/esieequest/Main.java +++ b/src/esieequest/Main.java @@ -62,6 +62,10 @@ public class Main extends JApplet { view = new Window(); } + if(arguments.contains("--challenge")) { + game.getPlayer().setMaxNbSteps(50); + } + new GameEngine(game, view); } diff --git a/src/esieequest/controller/Performer.java b/src/esieequest/controller/Performer.java index 7ba8c94..63cf75b 100644 --- a/src/esieequest/controller/Performer.java +++ b/src/esieequest/controller/Performer.java @@ -110,6 +110,7 @@ class Performer { if (nextRoom != null) { this.game.getPlayer().goToRoom(nextRoom); this.view.updateRoom(this.game.getPlayer().getCurrentRoom()); + this.walk(); } else { this.echo(this.game.getNoExitMessage()); } @@ -121,6 +122,15 @@ class Performer { public void goBack() { this.game.getPlayer().goToPreviousRoom(); this.view.updateRoom(this.game.getPlayer().getCurrentRoom()); + this.walk(); + } + + private void walk() { + this.game.getPlayer().setNbSteps(this.game.getPlayer().getNbSteps() + 1); + if (this.game.getPlayer().getNbSteps() == this.game.getPlayer().getMaxNbSteps()) { + this.echo("You died of exhaustion..."); + this.quitGame(); + } } /** diff --git a/src/esieequest/model/entities/Player.java b/src/esieequest/model/entities/Player.java index 91888eb..16ac612 100644 --- a/src/esieequest/model/entities/Player.java +++ b/src/esieequest/model/entities/Player.java @@ -12,6 +12,9 @@ public class Player { private final Inventory inventory; private final int maxCarryWeight; + + private int nbSteps; + private int maxNbSteps; public Player(final int maxCarryWeight) { this.currentRoom = null; @@ -19,6 +22,9 @@ public class Player { this.inventory = new Inventory(); this.maxCarryWeight = maxCarryWeight; + + this.nbSteps = 0; + this.maxNbSteps = 0; } /** @@ -66,4 +72,32 @@ public class Player { return this.maxCarryWeight; } + /** + * @return the nbSteps + */ + public int getNbSteps() { + return nbSteps; + } + + /** + * @param nbSteps the nbSteps to set + */ + public void setNbSteps(int nbSteps) { + this.nbSteps = nbSteps; + } + + /** + * @return the maxNbSteps + */ + public int getMaxNbSteps() { + return maxNbSteps; + } + + /** + * @param maxNbSteps the maxNbSteps to set + */ + public void setMaxNbSteps(int maxNbSteps) { + this.maxNbSteps = maxNbSteps; + } + } -- cgit v1.2.3 From 88228feaeaf2ab881fa1f914a99c15ac3d6c4b60 Mon Sep 17 00:00:00 2001 From: Benoît LUBRANO DI SBARAGLIONE Date: Wed, 9 Apr 2014 11:27:46 +0200 Subject: Correct sentence for no items in current room. --- src/esieequest/model/items/Inventory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/esieequest/model/items/Inventory.java b/src/esieequest/model/items/Inventory.java index 228386e..dddff8f 100644 --- a/src/esieequest/model/items/Inventory.java +++ b/src/esieequest/model/items/Inventory.java @@ -71,7 +71,7 @@ public class Inventory { * @return the list of items */ public String listItems() { - return Utils.list(this.items.keySet(), "Items:", "No items."); + return Utils.list(this.items.keySet(), "Items:", "No items here."); } /** -- cgit v1.2.3 From 432a7fde34d1305275cccb9cc42671f0d5d6c0c1 Mon Sep 17 00:00:00 2001 From: Benoît LUBRANO DI SBARAGLIONE Date: Wed, 9 Apr 2014 11:36:22 +0200 Subject: Update report: time limit. --- report/progression.tex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/report/progression.tex b/report/progression.tex index ccfff83..251601d 100644 --- a/report/progression.tex +++ b/report/progression.tex @@ -327,6 +327,10 @@ with the commit number 159b168b2. \subsection{Time limit} +The time limit was implemented as a steps limit for the player. When this limit +is reached, the game quits with a message. The argument --challenge is necessary +to enable this game mode. Commit number 2fee72805. + \subsubsection{Real time} \subsection{GUI} -- cgit v1.2.3 From 0276794641327ad41bc8aade12ac5befdfd3dcfb Mon Sep 17 00:00:00 2001 From: Benoît LUBRANO DI SBARAGLIONE Date: Wed, 9 Apr 2014 11:46:46 +0200 Subject: Correct formatting. --- src/esieequest/model/entities/Player.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/esieequest/model/entities/Player.java b/src/esieequest/model/entities/Player.java index 16ac612..aaa6651 100644 --- a/src/esieequest/model/entities/Player.java +++ b/src/esieequest/model/entities/Player.java @@ -5,6 +5,11 @@ import java.util.Stack; import esieequest.model.items.Inventory; import esieequest.model.map.Room; +/** + * + * @author Pacien TRAN-GIRARD + * @author Benoît LUBRANO DI SBARAGLIONE + */ public class Player { private Room currentRoom; @@ -12,7 +17,7 @@ public class Player { private final Inventory inventory; private final int maxCarryWeight; - + private int nbSteps; private int maxNbSteps; @@ -22,7 +27,7 @@ public class Player { this.inventory = new Inventory(); this.maxCarryWeight = maxCarryWeight; - + this.nbSteps = 0; this.maxNbSteps = 0; } @@ -80,7 +85,8 @@ public class Player { } /** - * @param nbSteps the nbSteps to set + * @param nbSteps + * the nbSteps to set */ public void setNbSteps(int nbSteps) { this.nbSteps = nbSteps; @@ -94,7 +100,8 @@ public class Player { } /** - * @param maxNbSteps the maxNbSteps to set + * @param maxNbSteps + * the maxNbSteps to set */ public void setMaxNbSteps(int maxNbSteps) { this.maxNbSteps = maxNbSteps; -- cgit v1.2.3 From 6e388ec789ba5897cc65a32cfac070c79c042eae Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 15 Apr 2014 20:08:49 +0200 Subject: Implement TrapDoor --- src/esieequest/Main.java | 4 +-- src/esieequest/controller/Performer.java | 18 ++++++++----- src/esieequest/model/Game.java | 43 ++++++++++++++----------------- src/esieequest/model/entities/Player.java | 15 ++++++++--- src/esieequest/model/map/Door.java | 20 ++++++++++++++ src/esieequest/model/map/Room.java | 8 +++--- src/esieequest/model/map/TrapDoor.java | 15 +++++++++++ 7 files changed, 84 insertions(+), 39 deletions(-) create mode 100644 src/esieequest/model/map/Door.java create mode 100644 src/esieequest/model/map/TrapDoor.java diff --git a/src/esieequest/Main.java b/src/esieequest/Main.java index e8cff08..362af9c 100755 --- a/src/esieequest/Main.java +++ b/src/esieequest/Main.java @@ -62,10 +62,10 @@ public class Main extends JApplet { view = new Window(); } - if(arguments.contains("--challenge")) { + if (arguments.contains("--challenge")) { game.getPlayer().setMaxNbSteps(50); } - + new GameEngine(game, view); } diff --git a/src/esieequest/controller/Performer.java b/src/esieequest/controller/Performer.java index 63cf75b..b5c32ba 100644 --- a/src/esieequest/controller/Performer.java +++ b/src/esieequest/controller/Performer.java @@ -6,7 +6,9 @@ import java.util.Set; import esieequest.model.Game; import esieequest.model.commands.CommandWord; import esieequest.model.items.Inventory; +import esieequest.model.map.Door; import esieequest.model.map.Room; +import esieequest.model.map.TrapDoor; import esieequest.view.View; /** @@ -106,13 +108,17 @@ class Performer { * the direction of the new room */ public void goTo(final String direction) { - final Room nextRoom = this.game.getPlayer().getCurrentRoom().getExit(direction); - if (nextRoom != null) { - this.game.getPlayer().goToRoom(nextRoom); - this.view.updateRoom(this.game.getPlayer().getCurrentRoom()); - this.walk(); - } else { + final Door door = this.game.getPlayer().getCurrentRoom().getExit(direction); + if (door == null) { this.echo(this.game.getNoExitMessage()); + return; + } + final Room nextRoom = door.getDestination(); + this.game.getPlayer().goToRoom(nextRoom); + this.view.updateRoom(this.game.getPlayer().getCurrentRoom()); + this.walk(); + if (door.getClass() == TrapDoor.class) { + this.game.getPlayer().clearRoomHistory(); } } diff --git a/src/esieequest/model/Game.java b/src/esieequest/model/Game.java index cc6157d..83fa143 100644 --- a/src/esieequest/model/Game.java +++ b/src/esieequest/model/Game.java @@ -4,7 +4,9 @@ import java.util.HashMap; import esieequest.model.entities.Player; import esieequest.model.items.Item; +import esieequest.model.map.Door; import esieequest.model.map.Room; +import esieequest.model.map.TrapDoor; /** * Represents the game. @@ -53,20 +55,6 @@ public class Game { this.rooms.put(name, new Room(description)); } - /** - * Sets the exit room of a given room designated by its name. - * - * @param roomName - * the name of the room - * @param direction - * the direction of the exit - * @param exitRoomName - * the name of the exit room - */ - private void setRoomExit(final String roomName, final String direction, final String exitRoomName) { - this.rooms.get(roomName).addExit(direction, this.rooms.get(exitRoomName)); - } - /** * Creates all the rooms. */ @@ -101,15 +89,28 @@ public class Game { this.createRoom("OffscriptItems", "somewhere implementing weight"); this.createRoom("OffscriptItemsStorageroom", "in a storage room"); - this.createRoom("OffscriptTime", "somewhere implementing time"); - this.createRoom("OffscriptTimeCountdownroom", "in a dangerous room"); this.createRoom("OffscriptTeleportation", "somewhere implementing teleportation"); this.createRoom("OffscriptTeleportationAnchorroom", "on a checkpoint"); this.createRoom("OffscriptAlea", "somewhere implementing alea"); this.createRoom("OffscriptAleaRandomizingroom", "in a weird room that will transport you somewhere else"); this.createRoom("OffscriptMovingcharacter", "somewhere implementing a moving character"); this.createRoom("OffscriptMovingcharacterSumobotroom", "in the Chirac-101's room"); + } + /** + * Sets the exit room of a given room designated by its name. + * + * @param roomName + * the name of the room + * @param direction + * the direction of the exit + * @param exitRoomName + * the name of the exit room + */ + private void setRoomExit(final String roomName, final String direction, final String exitRoomName) { + final Room room = this.rooms.get(exitRoomName); + final Door door = new Door(room); + this.rooms.get(roomName).addExit(direction, door); } /** @@ -153,7 +154,6 @@ public class Game { this.setRoomExit("WingStreet", "east", "ClubnixStreet"); this.setRoomExit("WingCorridorOne", "west", "WingStairsOne"); this.setRoomExit("WingCorridorOne", "south", "WingStreet"); - this.setRoomExit("WingCorridorOne", "east", "OffscriptItems"); this.setRoomExit("WingStairsOne", "south", "WingStairsTwo"); this.setRoomExit("WingStairsOne", "up", "WingStairsTwo"); this.setRoomExit("WingStairsOne", "east", "WingCorridorOne"); @@ -166,14 +166,11 @@ public class Game { this.setRoomExit("WingCorridorTwoOffice", "east", "WingOffice"); this.setRoomExit("WingOffice", "west", "WingCorridorTwoOffice"); + this.rooms.get("WingCorridorOne").addExit("east", new TrapDoor(this.rooms.get("OffscriptItems"))); + this.setRoomExit("OffscriptItems", "north", "OffscriptItemsStorageroom"); - this.setRoomExit("OffscriptItems", "west", "WingCorridorOne"); - this.setRoomExit("OffscriptItems", "east", "OffscriptTime"); + this.setRoomExit("OffscriptItems", "east", "OffscriptTeleportation"); this.setRoomExit("OffscriptItemsStorageroom", "south", "OffscriptItems"); - this.setRoomExit("OffscriptTime", "north", "OffscriptTimeCountdownroom"); - this.setRoomExit("OffscriptTime", "west", "OffscriptTakeStorageroom"); - this.setRoomExit("OffscriptTime", "east", "OffscriptTeleportation"); - this.setRoomExit("OffscriptTimeCountdownroom", "south", "OffscriptTime"); this.setRoomExit("OffscriptTeleportation", "north", "OffscriptTeleportationAnchorroom"); this.setRoomExit("OffscriptTeleportation", "west", "OffscriptTime"); this.setRoomExit("OffscriptTeleportation", "east", "OffscriptAlea"); diff --git a/src/esieequest/model/entities/Player.java b/src/esieequest/model/entities/Player.java index aaa6651..11a893f 100644 --- a/src/esieequest/model/entities/Player.java +++ b/src/esieequest/model/entities/Player.java @@ -61,6 +61,13 @@ public class Player { } } + /** + * Clears the previous rooms history. + */ + public void clearRoomHistory() { + this.previousRooms.clear(); + } + /** * Gets the player's inventory. * @@ -81,14 +88,14 @@ public class Player { * @return the nbSteps */ public int getNbSteps() { - return nbSteps; + return this.nbSteps; } /** * @param nbSteps * the nbSteps to set */ - public void setNbSteps(int nbSteps) { + public void setNbSteps(final int nbSteps) { this.nbSteps = nbSteps; } @@ -96,14 +103,14 @@ public class Player { * @return the maxNbSteps */ public int getMaxNbSteps() { - return maxNbSteps; + return this.maxNbSteps; } /** * @param maxNbSteps * the maxNbSteps to set */ - public void setMaxNbSteps(int maxNbSteps) { + public void setMaxNbSteps(final int maxNbSteps) { this.maxNbSteps = maxNbSteps; } diff --git a/src/esieequest/model/map/Door.java b/src/esieequest/model/map/Door.java new file mode 100644 index 0000000..303ea45 --- /dev/null +++ b/src/esieequest/model/map/Door.java @@ -0,0 +1,20 @@ +package esieequest.model.map; + +/** + * A door that links two rooms. + * + * @author Pacien TRAN-GIRARD + */ +public class Door { + + private final Room destination; + + public Door(final Room destination) { + this.destination = destination; + } + + public Room getDestination() { + return this.destination; + } + +} diff --git a/src/esieequest/model/map/Room.java b/src/esieequest/model/map/Room.java index fc20cc5..b39413d 100644 --- a/src/esieequest/model/map/Room.java +++ b/src/esieequest/model/map/Room.java @@ -18,7 +18,7 @@ public class Room { private final String description; private final String imageName; - private final HashMap exits; + private final HashMap exits; private final Inventory items; /** @@ -32,7 +32,7 @@ public class Room { public Room(final String description, final String imageName) { this.description = description; this.imageName = imageName; - this.exits = new HashMap(); + this.exits = new HashMap(); this.items = new Inventory(); } @@ -74,7 +74,7 @@ public class Room { * * @return the exit room */ - public Room getExit(final String direction) { + public Door getExit(final String direction) { return this.exits.get(direction); } @@ -95,7 +95,7 @@ public class Room { * @param neighbor * the room in the given direction */ - public void addExit(final String direction, final Room neighbor) { + public void addExit(final String direction, final Door neighbor) { this.exits.put(direction, neighbor); } diff --git a/src/esieequest/model/map/TrapDoor.java b/src/esieequest/model/map/TrapDoor.java new file mode 100644 index 0000000..b86e8b5 --- /dev/null +++ b/src/esieequest/model/map/TrapDoor.java @@ -0,0 +1,15 @@ +package esieequest.model.map; + +/** + * A one-way door that links two rooms and prevent the usage of the 'back' + * command. + * + * @author Pacien TRAN-GIRARD + */ +public class TrapDoor extends Door { + + public TrapDoor(final Room destination) { + super(destination); + } + +} -- cgit v1.2.3 From 35d771f9f0e96304fd37a046dffe480a26795e44 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 15 Apr 2014 20:11:10 +0200 Subject: Update report --- report/progression.tex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/report/progression.tex b/report/progression.tex index 251601d..069d2da 100644 --- a/report/progression.tex +++ b/report/progression.tex @@ -337,6 +337,10 @@ to enable this game mode. Commit number 2fee72805. \subsection{Trap door} +A TrapDoor was added to link the main map to the off-script map, and all Rooms +are linked through Doors since the commit number 6e388ec78. When crossing a +TrapDoor, the Performer clears the Player's previous Rooms Stack. + \subsection{Beamer} \subsection{Locked door} -- cgit v1.2.3 From 6a154d2feb6722cb0395bb1e69af2be5a76cdacc Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 15 Apr 2014 20:50:06 +0200 Subject: Implement the Beamer --- src/esieequest/controller/Interpreter.java | 24 +++++++++++------ src/esieequest/controller/Parser.java | 2 +- src/esieequest/controller/Performer.java | 27 ++++++++++++++++++-- src/esieequest/model/Game.java | 17 ++++++++----- src/esieequest/model/items/Beamer.java | 41 ++++++++++++++++++++++++++++++ src/esieequest/model/items/Inventory.java | 12 +++++++++ 6 files changed, 105 insertions(+), 18 deletions(-) create mode 100644 src/esieequest/model/items/Beamer.java diff --git a/src/esieequest/controller/Interpreter.java b/src/esieequest/controller/Interpreter.java index 32adeda..e09ad91 100644 --- a/src/esieequest/controller/Interpreter.java +++ b/src/esieequest/controller/Interpreter.java @@ -48,6 +48,8 @@ class Interpreter { public void dispatch(final Command command) { if (command.getAction() != null) { switch (command.getAction()) { + + // game related: case NEW: this.performer.newGame(); return; @@ -57,9 +59,17 @@ class Interpreter { case SAVE: this.performer.saveGame(); return; + case QUIT: + this.performer.quitGame(); + return; case SOUND: this.performer.toggleSound(); return; + case HELP: + this.performer.showHelp(); + return; + + // map related: case GO: this.performer.goTo(command.getOption()); return; @@ -69,25 +79,23 @@ class Interpreter { case LOOK: this.performer.look(); return; + + // items related: case INVENTORY: this.performer.listItems(); return; case TAKE: - this.performer.take(command.getOption()); + this.performer.takeItem(command.getOption()); return; case DROP: - this.performer.drop(command.getOption()); + this.performer.dropItem(command.getOption()); return; - case HELP: - this.performer.showHelp(); - return; - case QUIT: - this.performer.quitGame(); + case USE: + this.performer.useItem(command.getOption()); return; } } this.performer.echo("Unknown command."); return; } - } diff --git a/src/esieequest/controller/Parser.java b/src/esieequest/controller/Parser.java index 7b07efb..d13f940 100644 --- a/src/esieequest/controller/Parser.java +++ b/src/esieequest/controller/Parser.java @@ -25,7 +25,7 @@ class Parser { * @return the command */ public Command getCommand(final String commandString) { - final String[] elements = commandString.split(" "); + final String[] elements = commandString.split(" ", 2); CommandWord action = null; String option = null; diff --git a/src/esieequest/controller/Performer.java b/src/esieequest/controller/Performer.java index b5c32ba..add3fe5 100644 --- a/src/esieequest/controller/Performer.java +++ b/src/esieequest/controller/Performer.java @@ -5,7 +5,9 @@ import java.util.Set; import esieequest.model.Game; import esieequest.model.commands.CommandWord; +import esieequest.model.items.Beamer; import esieequest.model.items.Inventory; +import esieequest.model.items.Item; import esieequest.model.map.Door; import esieequest.model.map.Room; import esieequest.model.map.TrapDoor; @@ -152,7 +154,12 @@ class Performer { * @param itemName * the item's name */ - public void take(final String itemName) { + public void takeItem(final String itemName) { + if (!this.game.getPlayer().getCurrentRoom().getItems().hasItem(itemName)) { + this.echo("No such item in this room."); + return; + } + int weight = this.game.getPlayer().getInventory().getTotalWeight(); weight += this.game.getPlayer().getCurrentRoom().getItems().getItemWeight(itemName); final int maxWeight = this.game.getPlayer().getMaxCarryWeight(); @@ -171,7 +178,7 @@ class Performer { * @param itemName * the item's name */ - public void drop(final String itemName) { + public void dropItem(final String itemName) { this.moveItem(this.game.getPlayer().getInventory(), this.game.getPlayer().getCurrentRoom().getItems(), itemName); } @@ -200,4 +207,20 @@ class Performer { this.echo(Utils.list(this.game.getPlayer().getInventory().getItemList(), "Items:", "No item in your inventory.")); } + public void useItem(final String itemName) { + final Item item = this.game.getPlayer().getInventory().getItem(itemName); + if (item == null) { + this.echo("You don't have such item."); + return; + } + if (item.getClass() == Beamer.class) { + final Beamer beamer = (Beamer) item; + if (beamer.getRoom() == null) { + beamer.setRoom(this.game.getPlayer().getCurrentRoom()); + } else { + this.game.getPlayer().goToRoom(beamer.getRoom()); + } + } + } + } diff --git a/src/esieequest/model/Game.java b/src/esieequest/model/Game.java index 83fa143..6e6b191 100644 --- a/src/esieequest/model/Game.java +++ b/src/esieequest/model/Game.java @@ -3,6 +3,7 @@ package esieequest.model; import java.util.HashMap; import esieequest.model.entities.Player; +import esieequest.model.items.Beamer; import esieequest.model.items.Item; import esieequest.model.map.Door; import esieequest.model.map.Room; @@ -90,7 +91,7 @@ public class Game { this.createRoom("OffscriptItems", "somewhere implementing weight"); this.createRoom("OffscriptItemsStorageroom", "in a storage room"); this.createRoom("OffscriptTeleportation", "somewhere implementing teleportation"); - this.createRoom("OffscriptTeleportationAnchorroom", "on a checkpoint"); + this.createRoom("OffscriptTeleportationBeamerroom", "on a checkpoint"); this.createRoom("OffscriptAlea", "somewhere implementing alea"); this.createRoom("OffscriptAleaRandomizingroom", "in a weird room that will transport you somewhere else"); this.createRoom("OffscriptMovingcharacter", "somewhere implementing a moving character"); @@ -171,10 +172,10 @@ public class Game { this.setRoomExit("OffscriptItems", "north", "OffscriptItemsStorageroom"); this.setRoomExit("OffscriptItems", "east", "OffscriptTeleportation"); this.setRoomExit("OffscriptItemsStorageroom", "south", "OffscriptItems"); - this.setRoomExit("OffscriptTeleportation", "north", "OffscriptTeleportationAnchorroom"); - this.setRoomExit("OffscriptTeleportation", "west", "OffscriptTime"); + this.setRoomExit("OffscriptTeleportation", "north", "OffscriptTeleportationBeamerroom"); + this.setRoomExit("OffscriptTeleportation", "west", "OffscriptItems"); this.setRoomExit("OffscriptTeleportation", "east", "OffscriptAlea"); - this.setRoomExit("OffscriptTeleportationAnchorroom", "south", "OffscriptTeleportation"); + this.setRoomExit("OffscriptTeleportationBeamerroom", "south", "OffscriptTeleportation"); this.setRoomExit("OffscriptAlea", "north", "OffscriptAleaRandomizingroom"); this.setRoomExit("OffscriptAlea", "west", "OffscriptTeleportation"); this.setRoomExit("OffscriptAlea", "east", "OffscriptMovingcharacter"); @@ -188,9 +189,11 @@ public class Game { * Creates and adds items into rooms. */ private void createItems() { - this.rooms.get("Cafeteria").getItems().putItem("banana", new Item("A yellow banana", 5)); - this.rooms.get("Cafeteria").getItems().putItem("orange", new Item("An orange orange", 6)); - this.rooms.get("Cafeteria").getItems().putItem("anti-matter", new Item("A block of anti-matter with a negative mass", -10)); + this.rooms.get("OffscriptItemsStorageroom").getItems().putItem("Weighted Storage Cube", new Item("A Weighted Storage Cube.", 5)); + this.rooms.get("OffscriptItemsStorageroom").getItems().putItem("Edgeless Safety Cube", new Item("An Edgeless Safety Cube.", 5)); + this.rooms.get("OffscriptItemsStorageroom").getItems().putItem("Portable Black-hole", new Item("A portable black-hole that has a negative mass.", -10)); + + this.rooms.get("OffscriptTeleportationBeamerroom").getItems().putItem("Portable Quantum Tunelling Device", new Beamer("Basically a teleporter.", 2)); } /** diff --git a/src/esieequest/model/items/Beamer.java b/src/esieequest/model/items/Beamer.java new file mode 100644 index 0000000..ba8f361 --- /dev/null +++ b/src/esieequest/model/items/Beamer.java @@ -0,0 +1,41 @@ +package esieequest.model.items; + +import esieequest.model.map.Room; + +/** + * A beamer is a device that can be charged, and fired. When charged, it + * memorises the current room. When fired, it transports the Player back to the + * room where it was charged. + * + * @author Pacien TRAN-GIRARD + */ +public class Beamer extends Item { + + private Room room; + + /** + * Creates a Beamer. + * + * @param description + * @param weight + */ + public Beamer(final String description, final int weight) { + super(description, weight); + } + + /** + * @return the room + */ + public Room getRoom() { + return this.room; + } + + /** + * @param room + * the room to set + */ + public void setRoom(final Room room) { + this.room = room; + } + +} diff --git a/src/esieequest/model/items/Inventory.java b/src/esieequest/model/items/Inventory.java index dddff8f..6de8f1d 100644 --- a/src/esieequest/model/items/Inventory.java +++ b/src/esieequest/model/items/Inventory.java @@ -18,6 +18,18 @@ public class Inventory { this.items = new HashMap(); } + /** + * Returns an item from the inventory, without removing it. + * + * @param itemName + * the item's name + * + * @return the item + */ + public Item getItem(final String itemName) { + return this.items.get(itemName); + } + /** * Takes (returns and removes) an item from the inventory. * -- cgit v1.2.3 From e29566f5ef5866f0532b681f37084ff7f43c0af2 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 15 Apr 2014 20:51:55 +0200 Subject: Update report --- report/progression.tex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/report/progression.tex b/report/progression.tex index 069d2da..ada455a 100644 --- a/report/progression.tex +++ b/report/progression.tex @@ -343,6 +343,10 @@ TrapDoor, the Performer clears the Player's previous Rooms Stack. \subsection{Beamer} +A Beamer was added with the commit number 6a154d2fe. It can be used once picked +up via the ``use'' command. It alternatively memorises the player's current room +and teleports him back. + \subsection{Locked door} \subsection{Tests} -- cgit v1.2.3 From 60b19b1d3e4da557128361f916c6de4bfdeb3d30 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 15 Apr 2014 23:17:06 +0200 Subject: Update report --- report/progression.tex | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/report/progression.tex b/report/progression.tex index ada455a..95505c1 100644 --- a/report/progression.tex +++ b/report/progression.tex @@ -55,8 +55,11 @@ the room since commit e510b08d0. \subsection{Object diagram} +%TODO + \subsubsection{Changes on execution} +%TODO \section{Zuul with features} @@ -331,10 +334,11 @@ The time limit was implemented as a steps limit for the player. When this limit is reached, the game quits with a message. The argument --challenge is necessary to enable this game mode. Commit number 2fee72805. -\subsubsection{Real time} - \subsection{GUI} +The actuel GUI will be improved at the end of the project, when all new +functionnalities will be implemented. + \subsection{Trap door} A TrapDoor was added to link the main map to the off-script map, and all Rooms -- cgit v1.2.3 From e9c61548bd9a141587f1ff89a790b9dccdd0fa61 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Wed, 16 Apr 2014 00:48:30 +0200 Subject: Implement LockedDoor --- src/esieequest/controller/Performer.java | 13 ++++++-- src/esieequest/model/Game.java | 46 ++++++++++++++++++++++++----- src/esieequest/model/items/Beamer.java | 4 +-- src/esieequest/model/items/Inventory.java | 16 ++++++++-- src/esieequest/model/items/Item.java | 8 ++++- src/esieequest/model/items/KeyCard.java | 14 +++++++++ src/esieequest/model/map/LockedDoor.java | 49 +++++++++++++++++++++++++++++++ 7 files changed, 136 insertions(+), 14 deletions(-) create mode 100644 src/esieequest/model/items/KeyCard.java create mode 100644 src/esieequest/model/map/LockedDoor.java diff --git a/src/esieequest/controller/Performer.java b/src/esieequest/controller/Performer.java index add3fe5..de8d814 100644 --- a/src/esieequest/controller/Performer.java +++ b/src/esieequest/controller/Performer.java @@ -9,6 +9,7 @@ import esieequest.model.items.Beamer; import esieequest.model.items.Inventory; import esieequest.model.items.Item; import esieequest.model.map.Door; +import esieequest.model.map.LockedDoor; import esieequest.model.map.Room; import esieequest.model.map.TrapDoor; import esieequest.view.View; @@ -115,6 +116,14 @@ class Performer { this.echo(this.game.getNoExitMessage()); return; } + if (door.getClass() == LockedDoor.class) { + final LockedDoor lockedDoor = (LockedDoor) door; + final boolean authorised = this.game.getPlayer().getInventory().containsItem(lockedDoor.getKey()); + if (!authorised) { + this.echo("This door is locked."); + return; + } + } final Room nextRoom = door.getDestination(); this.game.getPlayer().goToRoom(nextRoom); this.view.updateRoom(this.game.getPlayer().getCurrentRoom()); @@ -155,7 +164,7 @@ class Performer { * the item's name */ public void takeItem(final String itemName) { - if (!this.game.getPlayer().getCurrentRoom().getItems().hasItem(itemName)) { + if (!this.game.getPlayer().getCurrentRoom().getItems().containsItem(itemName)) { this.echo("No such item in this room."); return; } @@ -193,7 +202,7 @@ class Performer { * the item's name */ private void moveItem(final Inventory source, final Inventory dest, final String itemName) { - if (!source.hasItem(itemName)) { + if (!source.containsItem(itemName)) { this.echo("No such item."); return; } diff --git a/src/esieequest/model/Game.java b/src/esieequest/model/Game.java index 6e6b191..0ff4b92 100644 --- a/src/esieequest/model/Game.java +++ b/src/esieequest/model/Game.java @@ -5,7 +5,9 @@ import java.util.HashMap; import esieequest.model.entities.Player; import esieequest.model.items.Beamer; import esieequest.model.items.Item; +import esieequest.model.items.KeyCard; import esieequest.model.map.Door; +import esieequest.model.map.LockedDoor; import esieequest.model.map.Room; import esieequest.model.map.TrapDoor; @@ -88,12 +90,22 @@ public class Game { this.createRoom("WingCorridorTwoOffice", "in front of the office #3254"); this.createRoom("WingOffice", "in the office #3254"); + // off-script rooms this.createRoom("OffscriptItems", "somewhere implementing weight"); this.createRoom("OffscriptItemsStorageroom", "in a storage room"); + this.createRoom("OffscriptTeleportation", "somewhere implementing teleportation"); this.createRoom("OffscriptTeleportationBeamerroom", "on a checkpoint"); + + this.createRoom("OffscriptTrap", "somewhere implementing a trap"); + this.createRoom("OffscriptTrapDeadend", "in a dead end"); + + this.createRoom("OffscriptLock", "somewhere implementing a lock"); + this.createRoom("OffscriptLockLockedroom", "in a locked room"); + this.createRoom("OffscriptAlea", "somewhere implementing alea"); this.createRoom("OffscriptAleaRandomizingroom", "in a weird room that will transport you somewhere else"); + this.createRoom("OffscriptMovingcharacter", "somewhere implementing a moving character"); this.createRoom("OffscriptMovingcharacterSumobotroom", "in the Chirac-101's room"); } @@ -167,15 +179,28 @@ public class Game { this.setRoomExit("WingCorridorTwoOffice", "east", "WingOffice"); this.setRoomExit("WingOffice", "west", "WingCorridorTwoOffice"); - this.rooms.get("WingCorridorOne").addExit("east", new TrapDoor(this.rooms.get("OffscriptItems"))); + this.rooms.get("WingCorridorOne").addExit("east", new Door(this.rooms.get("OffscriptItems"))); + // this.rooms.get("WingCorridorOne").addExit("east", new + // TrapDoor(this.rooms.get("OffscriptItems"))); this.setRoomExit("OffscriptItems", "north", "OffscriptItemsStorageroom"); this.setRoomExit("OffscriptItems", "east", "OffscriptTeleportation"); this.setRoomExit("OffscriptItemsStorageroom", "south", "OffscriptItems"); this.setRoomExit("OffscriptTeleportation", "north", "OffscriptTeleportationBeamerroom"); this.setRoomExit("OffscriptTeleportation", "west", "OffscriptItems"); - this.setRoomExit("OffscriptTeleportation", "east", "OffscriptAlea"); + this.setRoomExit("OffscriptTeleportation", "east", "OffscriptTrap"); this.setRoomExit("OffscriptTeleportationBeamerroom", "south", "OffscriptTeleportation"); + // this.setRoomExit("OffscriptTrap", "north", "OffscriptTrapDeadend"); + this.rooms.get("OffscriptTrap").addExit("north", new TrapDoor(this.rooms.get("OffscriptTrapDeadend"))); + this.setRoomExit("OffscriptTrap", "west", "OffscriptTeleportation"); + this.setRoomExit("OffscriptTrap", "east", "OffscriptLock"); + // this.setRoomExit("OffscriptTrapDeadend", "south", "OffscriptTrap"); + // this.setRoomExit("OffscriptLock", "north", "OffscriptLockedroom"); + this.rooms.get("OffscriptLock").addExit("north", new LockedDoor(this.rooms.get("OffscriptLockLockedroom"))); + this.setRoomExit("OffscriptLock", "west", "OffscriptTrap"); + this.setRoomExit("OffscriptLock", "east", "OffscriptAlea"); + // this.setRoomExit("OffscriptLockedroom", "south", "OffscriptLock"); + this.rooms.get("OffscriptLockLockedroom").addExit("south", new LockedDoor(this.rooms.get("OffscriptLock"))); this.setRoomExit("OffscriptAlea", "north", "OffscriptAleaRandomizingroom"); this.setRoomExit("OffscriptAlea", "west", "OffscriptTeleportation"); this.setRoomExit("OffscriptAlea", "east", "OffscriptMovingcharacter"); @@ -189,11 +214,18 @@ public class Game { * Creates and adds items into rooms. */ private void createItems() { - this.rooms.get("OffscriptItemsStorageroom").getItems().putItem("Weighted Storage Cube", new Item("A Weighted Storage Cube.", 5)); - this.rooms.get("OffscriptItemsStorageroom").getItems().putItem("Edgeless Safety Cube", new Item("An Edgeless Safety Cube.", 5)); - this.rooms.get("OffscriptItemsStorageroom").getItems().putItem("Portable Black-hole", new Item("A portable black-hole that has a negative mass.", -10)); - - this.rooms.get("OffscriptTeleportationBeamerroom").getItems().putItem("Portable Quantum Tunelling Device", new Beamer("Basically a teleporter.", 2)); + this.rooms.get("OffscriptItemsStorageroom").getItems().putItem("Weighted Storage Cube", new Item("A Weighted Storage Cube.", 5, true)); + this.rooms.get("OffscriptItemsStorageroom").getItems().putItem("Edgeless Safety Cube", new Item("An Edgeless Safety Cube.", 5, true)); + this.rooms.get("OffscriptItemsStorageroom").getItems().putItem("Portable Black-hole", new Item("A portable black-hole that has a negative mass.", -10, true)); + + this.rooms.get("OffscriptTeleportationBeamerroom").getItems().putItem("Portable Quantum Tunelling Device", new Beamer("Basically a teleporter.")); + + final KeyCard keyCard = new KeyCard("A KeyCard that opens a locked door."); + final LockedDoor lockedDoorLock = (LockedDoor) this.rooms.get("OffscriptLock").getExit("north"); + lockedDoorLock.setKey(keyCard); + final LockedDoor lockedDoorLockedRoom = (LockedDoor) this.rooms.get("OffscriptLockLockedroom").getExit("south"); + lockedDoorLockedRoom.setKey(keyCard); + this.rooms.get("OffscriptLock").getItems().putItem("KeyCard", keyCard); } /** diff --git a/src/esieequest/model/items/Beamer.java b/src/esieequest/model/items/Beamer.java index ba8f361..5618ea8 100644 --- a/src/esieequest/model/items/Beamer.java +++ b/src/esieequest/model/items/Beamer.java @@ -19,8 +19,8 @@ public class Beamer extends Item { * @param description * @param weight */ - public Beamer(final String description, final int weight) { - super(description, weight); + public Beamer(final String description) { + super(description, true); } /** diff --git a/src/esieequest/model/items/Inventory.java b/src/esieequest/model/items/Inventory.java index 6de8f1d..94691ad 100644 --- a/src/esieequest/model/items/Inventory.java +++ b/src/esieequest/model/items/Inventory.java @@ -45,17 +45,29 @@ public class Inventory { } /** - * Tells is an inventory contains a given item by its name. + * Tells if the inventory contains a given item by its name. * * @param itemName * the item's name * * @return the existence of the item */ - public boolean hasItem(final String itemName) { + public boolean containsItem(final String itemName) { return this.items.get(itemName) != null; } + /** + * Tells if the inventory contains a given item. + * + * @param item + * the item + * + * @return the existence of the item + */ + public boolean containsItem(final Item item) { + return this.items.containsValue(item); + } + /** * Puts an item in the inventory. * diff --git a/src/esieequest/model/items/Item.java b/src/esieequest/model/items/Item.java index 01bf3f3..b9d6deb 100644 --- a/src/esieequest/model/items/Item.java +++ b/src/esieequest/model/items/Item.java @@ -10,6 +10,7 @@ public class Item { private final String description; private final int weight; + private final boolean droppable; /** * Creates an item with the given characteristics. @@ -19,9 +20,14 @@ public class Item { * @param weight * the weight of the item */ - public Item(final String description, final int weight) { + public Item(final String description, final int weight, final boolean droppable) { this.description = description; this.weight = weight; + this.droppable = droppable; + } + + public Item(final String description, final boolean droppable) { + this(description, 0, droppable); } /** diff --git a/src/esieequest/model/items/KeyCard.java b/src/esieequest/model/items/KeyCard.java new file mode 100644 index 0000000..1579ee1 --- /dev/null +++ b/src/esieequest/model/items/KeyCard.java @@ -0,0 +1,14 @@ +package esieequest.model.items; + +/** + * A key-card that unlocks a Door. + * + * @author Pacien TRAN-GIRARD + */ +public class KeyCard extends Item { + + public KeyCard(final String description) { + super(description, false); + } + +} diff --git a/src/esieequest/model/map/LockedDoor.java b/src/esieequest/model/map/LockedDoor.java new file mode 100644 index 0000000..08a6513 --- /dev/null +++ b/src/esieequest/model/map/LockedDoor.java @@ -0,0 +1,49 @@ +package esieequest.model.map; + +import esieequest.model.items.KeyCard; + +/** + * A door that links two rooms and requires a keycard to pass through. + * + * @author Pacien TRAN-GIRARD + */ +public class LockedDoor extends Door { + + private KeyCard keyCard; + + public LockedDoor(final Room destination) { + super(destination); + } + + /** + * Returns the KeyCard that opens this door. + * + * @return the KeyCard + */ + public KeyCard getKey() { + return this.keyCard; + } + + /** + * Sets the KeyCard authorised to open this door. + * + * @param keyCard + * the KeyCard to set + */ + public void setKey(final KeyCard keyCard) { + this.keyCard = keyCard; + } + + /** + * Tells if a given KeyCard can open this door. + * + * @param keyCard + * the KeyCard + * + * @return + */ + public boolean isAuthorised(final KeyCard keyCard) { + return keyCard == this.keyCard; + } + +} -- cgit v1.2.3 From 9c539573868dd221088ae069e26a0b0ad35d2903 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Wed, 16 Apr 2014 00:49:55 +0200 Subject: Update report --- report/progression.tex | 3 +++ 1 file changed, 3 insertions(+) diff --git a/report/progression.tex b/report/progression.tex index 95505c1..3955944 100644 --- a/report/progression.tex +++ b/report/progression.tex @@ -353,6 +353,9 @@ and teleports him back. \subsection{Locked door} +A locked door was implement with the commit number e9c61548b. To pass through, +the player needs to pick up a corresponding key. + \subsection{Tests} \subsection{Transporter room} -- cgit v1.2.3 From ef51d51372df08de05a1ac35903ee4d6d9490328 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Wed, 16 Apr 2014 00:54:30 +0200 Subject: Implement undroppable items --- src/esieequest/controller/Performer.java | 4 ++++ src/esieequest/model/items/Item.java | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/esieequest/controller/Performer.java b/src/esieequest/controller/Performer.java index de8d814..8c61f3a 100644 --- a/src/esieequest/controller/Performer.java +++ b/src/esieequest/controller/Performer.java @@ -188,6 +188,10 @@ class Performer { * the item's name */ public void dropItem(final String itemName) { + if (!this.game.getPlayer().getInventory().getItem(itemName).isDroppable()) { + this.echo("This item cannot be dropped."); + return; + } this.moveItem(this.game.getPlayer().getInventory(), this.game.getPlayer().getCurrentRoom().getItems(), itemName); } diff --git a/src/esieequest/model/items/Item.java b/src/esieequest/model/items/Item.java index b9d6deb..8f5582b 100644 --- a/src/esieequest/model/items/Item.java +++ b/src/esieequest/model/items/Item.java @@ -48,4 +48,13 @@ public class Item { return this.weight; } + /** + * Tells whether the item is droppable. + * + * @return the droppability of the item. + */ + public boolean isDroppable() { + return this.droppable; + } + } -- cgit v1.2.3 From 72334d8f1ac5310b82923401170f6099d24f9f6c Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Wed, 16 Apr 2014 00:55:22 +0200 Subject: Update report --- report/progression.tex | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/report/progression.tex b/report/progression.tex index 3955944..dc63a56 100644 --- a/report/progression.tex +++ b/report/progression.tex @@ -384,6 +384,12 @@ the player needs to pick up a corresponding key. \section{Zuul awesome} +\subsection{Non-droppable items} + +Non-droppable items were added with the commit number ef51d5137. + +\subsection{Hidden doors} + \subsection{Room sides} \subsection{Quests} -- cgit v1.2.3 From 20c9b8b28655f0e81e05ef854e605e809b396977 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Wed, 16 Apr 2014 01:02:22 +0200 Subject: Implement HiddenDoor --- src/esieequest/model/Game.java | 3 ++- src/esieequest/model/map/HiddenDoor.java | 14 ++++++++++++++ src/esieequest/model/map/Room.java | 9 ++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/esieequest/model/map/HiddenDoor.java diff --git a/src/esieequest/model/Game.java b/src/esieequest/model/Game.java index 0ff4b92..8de81b2 100644 --- a/src/esieequest/model/Game.java +++ b/src/esieequest/model/Game.java @@ -7,6 +7,7 @@ import esieequest.model.items.Beamer; import esieequest.model.items.Item; import esieequest.model.items.KeyCard; import esieequest.model.map.Door; +import esieequest.model.map.HiddenDoor; import esieequest.model.map.LockedDoor; import esieequest.model.map.Room; import esieequest.model.map.TrapDoor; @@ -179,7 +180,7 @@ public class Game { this.setRoomExit("WingCorridorTwoOffice", "east", "WingOffice"); this.setRoomExit("WingOffice", "west", "WingCorridorTwoOffice"); - this.rooms.get("WingCorridorOne").addExit("east", new Door(this.rooms.get("OffscriptItems"))); + this.rooms.get("WingCorridorOne").addExit("east", new HiddenDoor(this.rooms.get("OffscriptItems"))); // this.rooms.get("WingCorridorOne").addExit("east", new // TrapDoor(this.rooms.get("OffscriptItems"))); diff --git a/src/esieequest/model/map/HiddenDoor.java b/src/esieequest/model/map/HiddenDoor.java new file mode 100644 index 0000000..243e09d --- /dev/null +++ b/src/esieequest/model/map/HiddenDoor.java @@ -0,0 +1,14 @@ +package esieequest.model.map; + +/** + * A hidden door that is not shown. + * + * @author Pacien TRAN-GIRARD + */ +public class HiddenDoor extends Door { + + public HiddenDoor(final Room destination) { + super(destination); + } + +} diff --git a/src/esieequest/model/map/Room.java b/src/esieequest/model/map/Room.java index b39413d..421e781 100644 --- a/src/esieequest/model/map/Room.java +++ b/src/esieequest/model/map/Room.java @@ -1,6 +1,7 @@ package esieequest.model.map; import java.util.HashMap; +import java.util.HashSet; import esieequest.controller.Utils; import esieequest.model.items.Inventory; @@ -84,7 +85,13 @@ public class Room { * @return the list of the available exits */ private String listExits() { - return Utils.list(this.exits.keySet(), "Available exits:", "This room has no exit."); + final HashSet exits = new HashSet(); + for (final String exit : this.exits.keySet()) { + if (this.exits.get(exit).getClass() != HiddenDoor.class) { + exits.add(exit); + } + } + return Utils.list(exits, "Available exits:", "This room has no exit."); } /** -- cgit v1.2.3 From 1e98d1fece7b0b8192a7f99c2238e1df2295406c Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Wed, 16 Apr 2014 01:03:09 +0200 Subject: Update report --- report/progression.tex | 3 +++ 1 file changed, 3 insertions(+) diff --git a/report/progression.tex b/report/progression.tex index dc63a56..d2e8598 100644 --- a/report/progression.tex +++ b/report/progression.tex @@ -390,6 +390,9 @@ Non-droppable items were added with the commit number ef51d5137. \subsection{Hidden doors} +Hidden Doors that are not shown as exits were added with the commit number +20c9b8b28. + \subsection{Room sides} \subsection{Quests} -- cgit v1.2.3 From d45490960b97ba81b9ea92355b1f49121db48531 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Wed, 16 Apr 2014 01:14:22 +0200 Subject: Complete JavaDoc --- src/esieequest/controller/Performer.java | 13 +++++++++++++ src/esieequest/model/entities/Player.java | 1 + src/esieequest/model/events/Quest.java | 5 +++++ src/esieequest/model/items/Beamer.java | 8 ++++++-- src/esieequest/model/items/Inventory.java | 7 ++++++- src/esieequest/model/items/KeyCard.java | 6 ++++++ src/esieequest/model/map/Door.java | 11 +++++++++++ src/esieequest/model/map/HiddenDoor.java | 6 ++++++ src/esieequest/model/map/LockedDoor.java | 6 ++++++ src/esieequest/model/map/TrapDoor.java | 6 ++++++ 10 files changed, 66 insertions(+), 3 deletions(-) diff --git a/src/esieequest/controller/Performer.java b/src/esieequest/controller/Performer.java index 8c61f3a..eb1cf9a 100644 --- a/src/esieequest/controller/Performer.java +++ b/src/esieequest/controller/Performer.java @@ -60,6 +60,7 @@ class Performer { */ public void newGame() { // this.loadGame(default game); + // TODO this.view.enable(); this.echo(this.game.getWelcomeMessage()); } @@ -68,6 +69,7 @@ class Performer { * Loads a saved game. */ public void loadGame() { + // TODO this.notImplemented(); } @@ -75,6 +77,7 @@ class Performer { * Saves the current game. */ public void saveGame() { + // TODO this.notImplemented(); } @@ -82,6 +85,7 @@ class Performer { * Toggles the sound. */ public void toggleSound() { + // TODO this.notImplemented(); } @@ -142,6 +146,9 @@ class Performer { this.walk(); } + /** + * Increments and checks the number of steps made by the player. + */ private void walk() { this.game.getPlayer().setNbSteps(this.game.getPlayer().getNbSteps() + 1); if (this.game.getPlayer().getNbSteps() == this.game.getPlayer().getMaxNbSteps()) { @@ -220,6 +227,12 @@ class Performer { this.echo(Utils.list(this.game.getPlayer().getInventory().getItemList(), "Items:", "No item in your inventory.")); } + /** + * Performs an action according to the use of an item. + * + * @param itemName + * the item's name + */ public void useItem(final String itemName) { final Item item = this.game.getPlayer().getInventory().getItem(itemName); if (item == null) { diff --git a/src/esieequest/model/entities/Player.java b/src/esieequest/model/entities/Player.java index 11a893f..4190eaa 100644 --- a/src/esieequest/model/entities/Player.java +++ b/src/esieequest/model/entities/Player.java @@ -6,6 +6,7 @@ import esieequest.model.items.Inventory; import esieequest.model.map.Room; /** + * A player. * * @author Pacien TRAN-GIRARD * @author Benoît LUBRANO DI SBARAGLIONE diff --git a/src/esieequest/model/events/Quest.java b/src/esieequest/model/events/Quest.java index 352d764..30c4aa0 100644 --- a/src/esieequest/model/events/Quest.java +++ b/src/esieequest/model/events/Quest.java @@ -1,5 +1,10 @@ package esieequest.model.events; +/** + * A quest that can be completed in the game. + * + * @author Pacien TRAN-GIRARD + */ public class Quest { private String title; diff --git a/src/esieequest/model/items/Beamer.java b/src/esieequest/model/items/Beamer.java index 5618ea8..a1e0c34 100644 --- a/src/esieequest/model/items/Beamer.java +++ b/src/esieequest/model/items/Beamer.java @@ -14,16 +14,18 @@ public class Beamer extends Item { private Room room; /** - * Creates a Beamer. + * Creates a new Beamer. * * @param description - * @param weight + * the description of the Beamer */ public Beamer(final String description) { super(description, true); } /** + * Returns the memorised Room. + * * @return the room */ public Room getRoom() { @@ -31,6 +33,8 @@ public class Beamer extends Item { } /** + * Sets the Room to memorise. + * * @param room * the room to set */ diff --git a/src/esieequest/model/items/Inventory.java b/src/esieequest/model/items/Inventory.java index 94691ad..6091872 100644 --- a/src/esieequest/model/items/Inventory.java +++ b/src/esieequest/model/items/Inventory.java @@ -103,12 +103,17 @@ public class Inventory { * * @param itemName * the item's name - * @return + * @return the weight of the item */ public int getItemWeight(final String itemName) { return this.items.get(itemName).getWeight(); } + /** + * Returns the sum of the weight of all the items. + * + * @return the total weight + */ public int getTotalWeight() { int totalWeight = 0; for (final Item item : this.items.values()) { diff --git a/src/esieequest/model/items/KeyCard.java b/src/esieequest/model/items/KeyCard.java index 1579ee1..dee3a08 100644 --- a/src/esieequest/model/items/KeyCard.java +++ b/src/esieequest/model/items/KeyCard.java @@ -7,6 +7,12 @@ package esieequest.model.items; */ public class KeyCard extends Item { + /** + * Creates a new KeyCard + * + * @param description + * the description of the KeyCard + */ public KeyCard(final String description) { super(description, false); } diff --git a/src/esieequest/model/map/Door.java b/src/esieequest/model/map/Door.java index 303ea45..122b529 100644 --- a/src/esieequest/model/map/Door.java +++ b/src/esieequest/model/map/Door.java @@ -9,10 +9,21 @@ public class Door { private final Room destination; + /** + * Creates a new Door. + * + * @param destination + * the destination Room + */ public Door(final Room destination) { this.destination = destination; } + /** + * Returns the destination Room. + * + * @return the destination Room + */ public Room getDestination() { return this.destination; } diff --git a/src/esieequest/model/map/HiddenDoor.java b/src/esieequest/model/map/HiddenDoor.java index 243e09d..e90dc61 100644 --- a/src/esieequest/model/map/HiddenDoor.java +++ b/src/esieequest/model/map/HiddenDoor.java @@ -7,6 +7,12 @@ package esieequest.model.map; */ public class HiddenDoor extends Door { + /** + * Creates a hidden door. + * + * @param destination + * the destination Room. + */ public HiddenDoor(final Room destination) { super(destination); } diff --git a/src/esieequest/model/map/LockedDoor.java b/src/esieequest/model/map/LockedDoor.java index 08a6513..6f5f15e 100644 --- a/src/esieequest/model/map/LockedDoor.java +++ b/src/esieequest/model/map/LockedDoor.java @@ -11,6 +11,12 @@ public class LockedDoor extends Door { private KeyCard keyCard; + /** + * Creates a new locked door. + * + * @param destination + * the destination Room + */ public LockedDoor(final Room destination) { super(destination); } diff --git a/src/esieequest/model/map/TrapDoor.java b/src/esieequest/model/map/TrapDoor.java index b86e8b5..7b8de7e 100644 --- a/src/esieequest/model/map/TrapDoor.java +++ b/src/esieequest/model/map/TrapDoor.java @@ -8,6 +8,12 @@ package esieequest.model.map; */ public class TrapDoor extends Door { + /** + * Creates a new trap door. + * + * @param destination + * the destination Room. + */ public TrapDoor(final Room destination) { super(destination); } -- cgit v1.2.3 From b9ced312ad75ae0bb1d0a50dadf1f0791ad6b0fd Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Wed, 16 Apr 2014 01:22:03 +0200 Subject: Update test files --- test/commands.txt | 43 ++++++++++++++++++++++++++++++------------- test/explore.txt | 23 +---------------------- 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/test/commands.txt b/test/commands.txt index d4eab7d..cc8b061 100644 --- a/test/commands.txt +++ b/test/commands.txt @@ -1,18 +1,35 @@ help -// go to the cafeteria to test the inventory +// go to the off-script rooms go north go west -take banana -look -take orange -look -take anti-matter -look -drop banana -look -drop orange -look -drop anti-matter -look +go north +go east +go east +go east +go north +go east +go north +take Weighted Storage Cube +take Edgeless Safety Cube +take Portable Black-hole +take Edgeless Safety Cube +go south +go east +go north +take Portable Quantum Tunneling Device +use Portable Quantum Tunneling Device +go south +go east +go north +go south +use Portable Quantum Tunneling Device +go south +go east +go east +go north +take KeyCard +go north +drop KeyCard +go south // quit \ No newline at end of file diff --git a/test/explore.txt b/test/explore.txt index efb9e68..e99c900 100644 --- a/test/explore.txt +++ b/test/explore.txt @@ -30,25 +30,4 @@ go east go south go east go north -// Going in off-script rooms -go south -go west -go north -go west -go north -// Entering in the WC -go east -go north -go south -go east -go north -go south -go east -go north -go south -go east -go north -go south -go east -go north -go south \ No newline at end of file +// we don't want to explore off-script rooms that have special behaviours \ No newline at end of file -- cgit v1.2.3 From a4a150d159291fdabdde45e5e034cbda3a63ba24 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Wed, 16 Apr 2014 01:22:09 +0200 Subject: Fix typo --- src/esieequest/model/Game.java | 2 +- src/esieequest/model/entities/Player.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/esieequest/model/Game.java b/src/esieequest/model/Game.java index 8de81b2..d1607a9 100644 --- a/src/esieequest/model/Game.java +++ b/src/esieequest/model/Game.java @@ -219,7 +219,7 @@ public class Game { this.rooms.get("OffscriptItemsStorageroom").getItems().putItem("Edgeless Safety Cube", new Item("An Edgeless Safety Cube.", 5, true)); this.rooms.get("OffscriptItemsStorageroom").getItems().putItem("Portable Black-hole", new Item("A portable black-hole that has a negative mass.", -10, true)); - this.rooms.get("OffscriptTeleportationBeamerroom").getItems().putItem("Portable Quantum Tunelling Device", new Beamer("Basically a teleporter.")); + this.rooms.get("OffscriptTeleportationBeamerroom").getItems().putItem("Portable Quantum Tunneling Device", new Beamer("Basically a teleporter.")); final KeyCard keyCard = new KeyCard("A KeyCard that opens a locked door."); final LockedDoor lockedDoorLock = (LockedDoor) this.rooms.get("OffscriptLock").getExit("north"); diff --git a/src/esieequest/model/entities/Player.java b/src/esieequest/model/entities/Player.java index 4190eaa..841d6a6 100644 --- a/src/esieequest/model/entities/Player.java +++ b/src/esieequest/model/entities/Player.java @@ -22,6 +22,13 @@ public class Player { private int nbSteps; private int maxNbSteps; + /** + * Creates a new player. + * + * @param maxCarryWeight + * the maximum total weight of the items that the player can + * carry + */ public Player(final int maxCarryWeight) { this.currentRoom = null; this.previousRooms = new Stack(); -- cgit v1.2.3 From ba422a863c58fb034e917621d0cb27f09f06183b Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Wed, 16 Apr 2014 01:22:50 +0200 Subject: Update report --- report/progression.tex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/report/progression.tex b/report/progression.tex index d2e8598..c2a36e9 100644 --- a/report/progression.tex +++ b/report/progression.tex @@ -358,6 +358,8 @@ the player needs to pick up a corresponding key. \subsection{Tests} +The test files were updated to fit the last modifications. + \subsection{Transporter room} \subsubsection{alea} -- cgit v1.2.3 From c5a7663453f6d67c2f4aa88a0e9756b6f24997d5 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Wed, 16 Apr 2014 15:51:17 +0200 Subject: Implement TransporterDoor --- src/esieequest/model/Game.java | 8 ++++--- src/esieequest/model/map/TransporterDoor.java | 30 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 src/esieequest/model/map/TransporterDoor.java diff --git a/src/esieequest/model/Game.java b/src/esieequest/model/Game.java index d1607a9..68dc1c2 100644 --- a/src/esieequest/model/Game.java +++ b/src/esieequest/model/Game.java @@ -1,6 +1,7 @@ package esieequest.model; import java.util.HashMap; +import java.util.HashSet; import esieequest.model.entities.Player; import esieequest.model.items.Beamer; @@ -10,6 +11,7 @@ import esieequest.model.map.Door; import esieequest.model.map.HiddenDoor; import esieequest.model.map.LockedDoor; import esieequest.model.map.Room; +import esieequest.model.map.TransporterDoor; import esieequest.model.map.TrapDoor; /** @@ -105,7 +107,6 @@ public class Game { this.createRoom("OffscriptLockLockedroom", "in a locked room"); this.createRoom("OffscriptAlea", "somewhere implementing alea"); - this.createRoom("OffscriptAleaRandomizingroom", "in a weird room that will transport you somewhere else"); this.createRoom("OffscriptMovingcharacter", "somewhere implementing a moving character"); this.createRoom("OffscriptMovingcharacterSumobotroom", "in the Chirac-101's room"); @@ -202,10 +203,11 @@ public class Game { this.setRoomExit("OffscriptLock", "east", "OffscriptAlea"); // this.setRoomExit("OffscriptLockedroom", "south", "OffscriptLock"); this.rooms.get("OffscriptLockLockedroom").addExit("south", new LockedDoor(this.rooms.get("OffscriptLock"))); - this.setRoomExit("OffscriptAlea", "north", "OffscriptAleaRandomizingroom"); + // this.setRoomExit("OffscriptAlea", "north", + // "OffscriptAleaRandomizingroom"); + this.rooms.get("OffscriptAlea").addExit("north", new TransporterDoor(new HashSet(this.rooms.values()))); this.setRoomExit("OffscriptAlea", "west", "OffscriptTeleportation"); this.setRoomExit("OffscriptAlea", "east", "OffscriptMovingcharacter"); - this.setRoomExit("OffscriptAleaRandomizingroom", "south", "OffscriptAlea"); this.setRoomExit("OffscriptMovingcharacter", "north", "OffscriptMovingcharacterSumobotroom"); this.setRoomExit("OffscriptMovingcharacter", "west", "OffscriptAlea"); this.setRoomExit("OffscriptMovingcharacterSumobotroom", "south", "OffscriptMovingcharacter"); diff --git a/src/esieequest/model/map/TransporterDoor.java b/src/esieequest/model/map/TransporterDoor.java new file mode 100644 index 0000000..8c5fc6e --- /dev/null +++ b/src/esieequest/model/map/TransporterDoor.java @@ -0,0 +1,30 @@ +package esieequest.model.map; + +import java.util.Random; +import java.util.Set; + +/** + * A door that transports the player in a random room. + * + * @author Pacien TRAN-GIRARD + */ +public class TransporterDoor extends Door { + + private final Set possibleDestinations; + + public TransporterDoor(final Set possibleDestinations) { + super(null); + this.possibleDestinations = possibleDestinations; + } + + @Override + public Room getDestination() { + return this.findRandomRoom(); + } + + private Room findRandomRoom() { + final int randomIndex = new Random().nextInt(this.possibleDestinations.size()); + return (Room) this.possibleDestinations.toArray()[randomIndex]; + } + +} -- cgit v1.2.3 From 1d45aca5c1a9213a5c2ec5f29bb07650d1e2f341 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Wed, 16 Apr 2014 16:14:27 +0200 Subject: Modify map to create an off-script sub-quest --- src/esieequest/controller/Performer.java | 2 +- src/esieequest/model/Game.java | 81 +++++++++++--------------------- 2 files changed, 28 insertions(+), 55 deletions(-) diff --git a/src/esieequest/controller/Performer.java b/src/esieequest/controller/Performer.java index eb1cf9a..59a3973 100644 --- a/src/esieequest/controller/Performer.java +++ b/src/esieequest/controller/Performer.java @@ -180,7 +180,7 @@ class Performer { weight += this.game.getPlayer().getCurrentRoom().getItems().getItemWeight(itemName); final int maxWeight = this.game.getPlayer().getMaxCarryWeight(); - if (weight >= maxWeight) { + if (weight > maxWeight) { this.echo("Maximum inventory weight reached. Cannot pick up item."); return; } diff --git a/src/esieequest/model/Game.java b/src/esieequest/model/Game.java index 68dc1c2..e5e3b56 100644 --- a/src/esieequest/model/Game.java +++ b/src/esieequest/model/Game.java @@ -94,22 +94,13 @@ public class Game { this.createRoom("WingOffice", "in the office #3254"); // off-script rooms - this.createRoom("OffscriptItems", "somewhere implementing weight"); - this.createRoom("OffscriptItemsStorageroom", "in a storage room"); + this.createRoom("Secret corridor 1", "in a secret corridor"); + this.createRoom("Secret corridor 2", "at the end of a secret corridor"); + this.createRoom("Storage room", "in a storage room"); + this.createRoom("Secret lab", "in a secret lab"); + this.createRoom("Dead-end", "in a dead end"); + this.createRoom("Locked room", "in a locked room"); - this.createRoom("OffscriptTeleportation", "somewhere implementing teleportation"); - this.createRoom("OffscriptTeleportationBeamerroom", "on a checkpoint"); - - this.createRoom("OffscriptTrap", "somewhere implementing a trap"); - this.createRoom("OffscriptTrapDeadend", "in a dead end"); - - this.createRoom("OffscriptLock", "somewhere implementing a lock"); - this.createRoom("OffscriptLockLockedroom", "in a locked room"); - - this.createRoom("OffscriptAlea", "somewhere implementing alea"); - - this.createRoom("OffscriptMovingcharacter", "somewhere implementing a moving character"); - this.createRoom("OffscriptMovingcharacterSumobotroom", "in the Chirac-101's room"); } /** @@ -180,55 +171,37 @@ public class Game { this.setRoomExit("WingCorridorTwoOffice", "south", "WingCorridorTwo"); this.setRoomExit("WingCorridorTwoOffice", "east", "WingOffice"); this.setRoomExit("WingOffice", "west", "WingCorridorTwoOffice"); + this.rooms.get("WingCorridorOne").addExit("east", new HiddenDoor(this.rooms.get("Secret corridor 1"))); + + this.setRoomExit("Secret corridor 1", "west", "WingCorridorOne"); + this.setRoomExit("Secret corridor 1", "east", "Secret corridor 2"); + this.setRoomExit("Secret corridor 2", "west", "Secret corridor 1"); + + this.setRoomExit("Secret corridor 1", "north", "Storage room"); + this.setRoomExit("Storage room", "south", "Secret corridor 1"); + this.setRoomExit("Secret corridor 1", "south", "Secret lab"); + this.setRoomExit("Secret lab", "north", "Secret corridor 1"); - this.rooms.get("WingCorridorOne").addExit("east", new HiddenDoor(this.rooms.get("OffscriptItems"))); - // this.rooms.get("WingCo