aboutsummaryrefslogtreecommitdiff
path: root/src/esieequest/model/Game.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/esieequest/model/Game.java')
-rw-r--r--src/esieequest/model/Game.java115
1 files changed, 68 insertions, 47 deletions
diff --git a/src/esieequest/model/Game.java b/src/esieequest/model/Game.java
index cc6157d..87d3d51 100644
--- a/src/esieequest/model/Game.java
+++ b/src/esieequest/model/Game.java
@@ -1,10 +1,19 @@
1package esieequest.model; 1package esieequest.model;
2 2
3import java.util.HashMap; 3import java.util.HashMap;
4import java.util.HashSet;
4 5
5import esieequest.model.entities.Player; 6import esieequest.model.entities.Player;
7import esieequest.model.entities.Sumobot;
8import esieequest.model.items.Beamer;
6import esieequest.model.items.Item; 9import esieequest.model.items.Item;
10import esieequest.model.items.KeyCard;
11import esieequest.model.map.Door;
12import esieequest.model.map.HiddenDoor;
13import esieequest.model.map.LockedDoor;
7import esieequest.model.map.Room; 14import esieequest.model.map.Room;
15import esieequest.model.map.TransporterDoor;
16import esieequest.model.map.TrapDoor;
8 17
9/** 18/**
10 * Represents the game. 19 * Represents the game.
@@ -29,6 +38,7 @@ public class Game {
29 this.createRooms(); 38 this.createRooms();
30 this.linkRooms(); 39 this.linkRooms();
31 this.createItems(); 40 this.createItems();
41 this.createCharacters();
32 this.goToRoom("AmphitheaterSeat"); 42 this.goToRoom("AmphitheaterSeat");
33 } 43 }
34 44
@@ -54,20 +64,6 @@ public class Game {
54 } 64 }
55 65
56 /** 66 /**
57 * Sets the exit room of a given room designated by its name.
58 *
59 * @param roomName
60 * the name of the room
61 * @param direction
62 * the direction of the exit
63 * @param exitRoomName
64 * the name of the exit room
65 */
66 private void setRoomExit(final String roomName, final String direction, final String exitRoomName) {
67 this.rooms.get(roomName).addExit(direction, this.rooms.get(exitRoomName));
68 }
69
70 /**
71 * Creates all the rooms. 67 * Creates all the rooms.
72 */ 68 */
73 private void createRooms() { 69 private void createRooms() {
@@ -99,20 +95,33 @@ public class Game {
99 this.createRoom("WingCorridorTwoOffice", "in front of the office #3254"); 95 this.createRoom("WingCorridorTwoOffice", "in front of the office #3254");
100 this.createRoom("WingOffice", "in the office #3254"); 96 this.createRoom("WingOffice", "in the office #3254");
101 97
102 this.createRoom("OffscriptItems", "somewhere implementing weight"); 98 // off-script rooms
103 this.createRoom("OffscriptItemsStorageroom", "in a storage room"); 99 this.createRoom("Secret corridor 1", "in a secret corridor");
104 this.createRoom("OffscriptTime", "somewhere implementing time"); 100 this.createRoom("Secret corridor 2", "at the end of a secret corridor");
105 this.createRoom("OffscriptTimeCountdownroom", "in a dangerous room"); 101 this.createRoom("Storage room", "in a storage room");
106 this.createRoom("OffscriptTeleportation", "somewhere implementing teleportation"); 102 this.createRoom("Secret lab", "in a secret lab");
107 this.createRoom("OffscriptTeleportationAnchorroom", "on a checkpoint"); 103 this.createRoom("Dead-end", "in a dead end");
108 this.createRoom("OffscriptAlea", "somewhere implementing alea"); 104 this.createRoom("Locked room", "in a locked room");
109 this.createRoom("OffscriptAleaRandomizingroom", "in a weird room that will transport you somewhere else");
110 this.createRoom("OffscriptMovingcharacter", "somewhere implementing a moving character");
111 this.createRoom("OffscriptMovingcharacterSumobotroom", "in the Chirac-101's room");
112 105
113 } 106 }
114 107
115 /** 108 /**
109 * Sets the exit room of a given room designated by its name.
110 *
111 * @param roomName
112 * the name of the room
113 * @param direction
114 * the direction of the exit
115 * @param exitRoomName
116 * the name of the exit room
117 */
118 private void setRoomExit(final String roomName, final String direction, final String exitRoomName) {
119 final Room room = this.rooms.get(exitRoomName);
120 final Door door = new Door(room);
121 this.rooms.get(roomName).addExit(direction, door);
122 }
123
124 /**
116 * Connects all the rooms. 125 * Connects all the rooms.
117 */ 126 */
118 private void linkRooms() { 127 private void linkRooms() {
@@ -153,7 +162,6 @@ public class Game {
153 this.setRoomExit("WingStreet", "east", "ClubnixStreet"); 162 this.setRoomExit("WingStreet", "east", "ClubnixStreet");
154 this.setRoomExit("WingCorridorOne", "west", "WingStairsOne"); 163 this.setRoomExit("WingCorridorOne", "west", "WingStairsOne");
155 this.setRoomExit("WingCorridorOne", "south", "WingStreet"); 164 this.setRoomExit("WingCorridorOne", "south", "WingStreet");
156 this.setRoomExit("WingCorridorOne", "east", "OffscriptItems");
157 this.setRoomExit("WingStairsOne", "south", "WingStairsTwo"); 165 this.setRoomExit("WingStairsOne", "south", "WingStairsTwo");
158 this.setRoomExit("WingStairsOne", "up", "WingStairsTwo"); 166 this.setRoomExit("WingStairsOne", "up", "WingStairsTwo");
159 this.setRoomExit("WingStairsOne", "east", "WingCorridorOne"); 167 this.setRoomExit("WingStairsOne", "east", "WingCorridorOne");
@@ -165,35 +173,41 @@ public class Game {
165 this.setRoomExit("WingCorridorTwoOffice", "south", "WingCorridorTwo"); 173 this.setRoomExit("WingCorridorTwoOffice", "south", "WingCorridorTwo");
166 this.setRoomExit("WingCorridorTwoOffice", "east", "WingOffice"); 174 this.setRoomExit("WingCorridorTwoOffice", "east", "WingOffice");
167 this.setRoomExit("WingOffice", "west", "WingCorridorTwoOffice"); 175 this.setRoomExit("WingOffice", "west", "WingCorridorTwoOffice");
176 this.rooms.get("WingCorridorOne").addExit("east", new HiddenDoor(this.rooms.get("Secret corridor 1")));
177
178 this.setRoomExit("Secret corridor 1", "west", "WingCorridorOne");
179 this.setRoomExit("Secret corridor 1", "east", "Secret corridor 2");
180 this.setRoomExit("Secret corridor 2", "west", "Secret corridor 1");
168 181
169 this.setRoomExit("OffscriptItems", "north", "OffscriptItemsStorageroom"); 182 this.setRoomExit("Secret corridor 1", "north", "Storage room");
170 this.setRoomExit("OffscriptItems", "west", "WingCorridorOne"); 183 this.setRoomExit("Storage room", "south", "Secret corridor 1");
171 this.setRoomExit("OffscriptItems", "east", "OffscriptTime"); 184 this.setRoomExit("Secret corridor 1", "south", "Secret lab");
172 this.setRoomExit("OffscriptItemsStorageroom", "south", "OffscriptItems"); 185 this.setRoomExit("Secret lab", "north", "Secret corridor 1");
173 this.setRoomExit("OffscriptTime", "north", "OffscriptTimeCountdownroom"); 186
174 this.setRoomExit("OffscriptTime", "west", "OffscriptTakeStorageroom"); 187 this.rooms.get("Secret corridor 2").addExit("north", new TrapDoor(this.rooms.get("Dead-end")));
175 this.setRoomExit("OffscriptTime", "east", "OffscriptTeleportation"); 188 this.rooms.get("Secret corridor 2").addExit("south", new LockedDoor(this.rooms.get("Locked room")));
176 this.setRoomExit("OffscriptTimeCountdownroom", "south", "OffscriptTime"); 189 this.rooms.get("Locked room").addExit("north", new LockedDoor(this.rooms.get("Secret corridor 2")));
177 this.setRoomExit("OffscriptTeleportation", "north", "OffscriptTeleportationAnchorroom"); 190 this.rooms.get("Secret corridor 2").addExit("east", new TransporterDoor(new HashSet<Room>(this.rooms.values())));
178 this.setRoomExit("OffscriptTeleportation", "west", "OffscriptTime");
179 this.setRoomExit("OffscriptTeleportation", "east", "OffscriptAlea");
180 this.setRoomExit("OffscriptTeleportationAnchorroom", "south", "OffscriptTeleportation");
181 this.setRoomExit("OffscriptAlea", "north", "OffscriptAleaRandomizingroom");
182 this.setRoomExit("OffscriptAlea", "west", "OffscriptTeleportation");
183 this.setRoomExit("OffscriptAlea", "east", "OffscriptMovingcharacter");
184 this.setRoomExit("OffscriptAleaRandomizingroom", "south", "OffscriptAlea");
185 this.setRoomExit("OffscriptMovingcharacter", "north", "OffscriptMovingcharacterSumobotroom");
186 this.setRoomExit("OffscriptMovingcharacter", "west", "OffscriptAlea");
187 this.setRoomExit("OffscriptMovingcharacterSumobotroom", "south", "OffscriptMovingcharacter");
188 } 191 }
189 192
190 /** 193 /**
191 * Creates and adds items into rooms. 194 * Creates and adds items into rooms.
192 */ 195 */
193 private void createItems() { 196 private void createItems() {
194 this.rooms.get("Cafeteria").getItems().putItem("banana", new Item("A yellow banana", 5)); 197 this.rooms.get("Storage room").getItems().putItem("Weighted Storage Cube", new Item("A Weighted Storage Cube.", 5, true));
195 this.rooms.get("Cafeteria").getItems().putItem("orange", new Item("An orange orange", 6)); 198 this.rooms.get("Storage room").getItems().putItem("Edgeless Safety Cube", new Item("An Edgeless Safety Cube.", 5, true));
196 this.rooms.get("Cafeteria").getItems().putItem("anti-matter", new Item("A block of anti-matter with a negative mass", -10)); 199 this.rooms.get("Storage room").getItems().putItem("Portable Black-hole", new Item("A portable black-hole that has a negative mass.", -10, false));
200
201 this.rooms.get("Secret lab").getItems().putItem("Portable Quantum Tunneling Device", new Beamer("Basically a teleporter."));
202
203 final KeyCard keyCard = new KeyCard("A KeyCard that opens a locked door.");
204 ((LockedDoor) this.rooms.get("Secret corridor 2").getExit("south")).setKey(keyCard);
205 ((LockedDoor) this.rooms.get("Locked room").getExit("north")).setKey(keyCard);
206 this.rooms.get("Dead-end").getItems().putItem("KeyCard", keyCard);
207 }
208
209 private void createCharacters() {
210 this.rooms.get("Locked room").setCharacter(new Sumobot());
197 } 211 }
198 212
199 /** 213 /**
@@ -260,4 +274,11 @@ public class Game {
260 return "Available commands:"; 274 return "Available commands:";
261 } 275 }
262 276
277 /**
278 * @return the rooms
279 */
280 public HashMap<String, Room> getRooms() {
281 return this.rooms;
282 }
283
263} 284}