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 (limited to 'src') 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