aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/esieequest/Game.java120
-rw-r--r--src/esieequest/Room.java54
2 files changed, 105 insertions, 69 deletions
diff --git a/src/esieequest/Game.java b/src/esieequest/Game.java
index a00d901..a0e0cd2 100644
--- a/src/esieequest/Game.java
+++ b/src/esieequest/Game.java
@@ -78,49 +78,83 @@ public class Game {
78 Room vOffscriptMovingcharacterMo = new Room("in M-O's room"); 78 Room vOffscriptMovingcharacterMo = new Room("in M-O's room");
79 79
80 // connect rooms (N, W, S, E) 80 // connect rooms (N, W, S, E)
81 vAmphitheaterSeat.setExits(vAmphitheaterStage, null, null, null); 81 vAmphitheaterSeat.setExit("north", vAmphitheaterStage);
82 vAmphitheaterStage.setExits(null, vCafeteria, null, null); 82 vAmphitheaterStage.setExit("west", vCafeteria);
83 83
84 vCafeteriaStreet.setExits(null, null, vCafeteria, vEsieespaceStreet); 84 vCafeteriaStreet.setExit("south", vCafeteria);
85 vCafeteria.setExits(vCafeteriaStreet, null, null, vAmphitheaterStage); 85 vCafeteriaStreet.setExit("east", vEsieespaceStreet);
86 86 vCafeteria.setExit("north", vCafeteriaStreet);
87 vEsieespaceStreet.setExits(null, vCafeteria, vEsieespaceFront, vEntranceStreet); 87 vCafeteria.setExit("east", vAmphitheaterStage);
88 vEsieespaceFront.setExits(vEsieespaceStreet, null, null, vEsieespaceEntrance); 88
89 vEsieespaceEntrance.setExits(vEsieespace, vEsieespaceFront, null, null); 89 vEsieespaceStreet.setExit("west", vCafeteria);
90 vEsieespace.setExits(null, null, vEsieespaceEntrance, null); 90 vEsieespaceStreet.setExit("south", vEsieespaceFront);
91 91 vEsieespaceStreet.setExit("east", vEntranceStreet);
92 vClubnixStreet.setExits(null, vWingStreet, vClubnixFront, null); 92 vEsieespaceFront.setExit("north", vEsieespaceStreet);
93 vClubnixFront.setExits(vClubnixStreet, null, null, vClubnixEntrance); 93 vEsieespaceFront.setExit("east", vEsieespaceEntrance);
94 vClubnixEntrance.setExits(vClubnix, vClubnixFront, null, null); 94 vEsieespaceEntrance.setExit("north", vEsieespace);
95 vClubnix.setExits(null, null, vClubnixEntrance, null); 95 vEsieespaceEntrance.setExit("west", vEsieespaceFront);
96 96 vEsieespace.setExit("south", vEsieespaceEntrance);
97 vEntranceStreet.setExits(null, vEsieespaceStreet, vEntranceStairs, vWingStreet); 97
98 vEntranceStairs.setExits(vEntranceStreet, null, vEntranceRoundabout, null); 98 vClubnixStreet.setExit("west", vWingStreet);
99 vEntranceRoundabout.setExits(vEntranceStairs, null, null, null); 99 vClubnixStreet.setExit("south", vClubnixFront);
100 100 vClubnixFront.setExit("north", vClubnixStreet);
101 vWingStreet.setExits(vWingCorridorOne, vEntranceStreet, null, vClubnixStreet); 101 vClubnixFront.setExit("east", vClubnixEntrance);
102 vWingCorridorOne.setExits(null, vWingStairsOne, vWingStreet, vOffscriptEat); 102 vClubnixEntrance.setExit("north", vClubnix);
103 vWingStairsOne.setExits(null, null, vWingStairsTwo, vWingCorridorOne); 103 vClubnixEntrance.setExit("west", vClubnixFront);
104 vWingStairsTwo.setExits(null, null, vWingStairsOne, vWingCorridorTwo); 104 vClubnix.setExit("south", vClubnixEntrance);
105 vWingCorridorTwo.setExits(vWingCorridorTwoOffice, null, null, null); 105
106 vWingCorridorTwoOffice.setExits(null, null, vWingCorridorTwo, vWingOffice); 106 vEntranceStreet.setExit("west", vEsieespaceStreet);
107 vWingOffice.setExits(null, vWingCorridorTwoOffice, null, null); 107 vEntranceStreet.setExit("south", vEntranceStairs);
108 108 vEntranceStreet.setExit("east", vWingStreet);
109 vOffscriptEat.setExits(vOffscriptEatPantry, vWingCorridorOne, null, vOffscriptTake); 109 vEntranceStairs.setExit("north", vEntranceStreet);
110 vOffscriptEatPantry.setExits(null, null, vOffscriptEat, null); 110 vEntranceStairs.setExit("south", vEntranceRoundabout);
111 vOffscriptTake.setExits(vOffscriptTakeStorageroom, vOffscriptEat, null, vOffscriptTimeout); 111 vEntranceRoundabout.setExit("north", vEntranceStairs);
112 vOffscriptTakeStorageroom.setExits(null, null, vOffscriptTake, null); 112
113 vOffscriptTimeout.setExits(vOffscriptTimeoutCountdownroom, vOffscriptTakeStorageroom, null, vOffscriptTrapdoor); 113 vWingStreet.setExit("north", vWingCorridorOne);
114 vOffscriptTimeoutCountdownroom.setExits(null, null, vOffscriptTimeout, null); 114 vWingStreet.setExit("west", vEntranceStreet);
115 vOffscriptTrapdoor.setExits(vOffscriptTrapdoorDeadend, vOffscriptTimeout, null, vOffscriptBeamer); 115 vWingStreet.setExit("east", vClubnixStreet);
116 vOffscriptTrapdoorDeadend.setExits(null, null, vOffscriptTrapdoor, null); 116 vWingCorridorOne.setExit("west", vWingStairsOne);
117 vOffscriptBeamer.setExits(vOffscriptBeamerAnchor, vOffscriptTrapdoor, null, vOffscriptLock); 117 vWingCorridorOne.setExit("south", vWingStreet);
118 vOffscriptBeamerAnchor.setExits(null, null, vOffscriptBeamer, null); 118 vWingCorridorOne.setExit("east", vOffscriptEat);
119 vOffscriptLock.setExits(vOffscriptLockLockedroom, vOffscriptBeamer, null, vOffscriptAlea); 119 vWingStairsOne.setExit("south", vWingStairsTwo);
120 vOffscriptLockLockedroom.setExits(null, null, vOffscriptLock, null); 120 vWingStairsOne.setExit("east", vWingCorridorOne);
121 vOffscriptAlea.setExits(vOffscriptAleaRoomrandomizer, vOffscriptLock, null, vOffscriptMovingcharacter); 121 vWingStairsTwo.setExit("south", vWingStairsOne);
122 vOffscriptAleaRoomrandomizer.setExits(null, null, vOffscriptAlea, null); 122 vWingStairsTwo.setExit("east", vWingCorridorTwo);
123 vOffscriptMovingcharacter.setExits(vOffscriptMovingcharacterMo, vOffscriptAlea, null, null); 123 vWingCorridorTwo.setExit("north", vWingCorridorTwoOffice);
124 vWingCorridorTwoOffice.setExit("south", vWingCorridorTwo);
125 vWingCorridorTwoOffice.setExit("east", vWingOffice);
126 vWingOffice.setExit("west", vWingCorridorTwoOffice);
127
128 vOffscriptEat.setExit("north", vOffscriptEatPantry);
129 vOffscriptEat.setExit("west", vWingCorridorOne);
130 vOffscriptEat.setExit("east", vOffscriptTake);
131 vOffscriptEatPantry.setExit("south", vOffscriptEat);
132 vOffscriptTake.setExit("north", vOffscriptTakeStorageroom);
133 vOffscriptTake.setExit("west", vOffscriptEat);
134 vOffscriptTake.setExit("east", vOffscriptTimeout);
135 vOffscriptTakeStorageroom.setExit("south", vOffscriptTake);
136 vOffscriptTimeout.setExit("north", vOffscriptTimeoutCountdownroom);
137 vOffscriptTimeout.setExit("west", vOffscriptTakeStorageroom);
138 vOffscriptTimeout.setExit("east", vOffscriptTrapdoor);
139 vOffscriptTimeoutCountdownroom.setExit("south", vOffscriptTimeout);
140 vOffscriptTrapdoor.setExit("north", vOffscriptTrapdoorDeadend);
141 vOffscriptTrapdoor.setExit("west", vOffscriptTimeout);
142 vOffscriptTrapdoor.setExit("east", vOffscriptBeamer);
143 vOffscriptTrapdoorDeadend.setExit("south", vOffscriptTrapdoor);
144 vOffscriptBeamer.setExit("north", vOffscriptBeamerAnchor);
145 vOffscriptBeamer.setExit("west", vOffscriptTrapdoor);
146 vOffscriptBeamer.setExit("east", vOffscriptLock);
147 vOffscriptBeamerAnchor.setExit("south", vOffscriptBeamer);
148 vOffscriptLock.setExit("north", vOffscriptLockLockedroom);
149 vOffscriptLock.setExit("west", vOffscriptBeamer);
150 vOffscriptLock.setExit("east", vOffscriptAlea);
151 vOffscriptLockLockedroom.setExit("south", vOffscriptLock);
152 vOffscriptAlea.setExit("north", vOffscriptAleaRoomrandomizer);
153 vOffscriptAlea.setExit("west", vOffscriptLock);
154 vOffscriptAlea.setExit("east", vOffscriptMovingcharacter);
155 vOffscriptAleaRoomrandomizer.setExit("south", vOffscriptAlea);
156 vOffscriptMovingcharacter.setExit("north", vOffscriptMovingcharacterMo);
157 vOffscriptMovingcharacter.setExit("west", vOffscriptAlea);
124 158
125 // set the starting room 159 // set the starting room
126 this.aCurrentRoom = vAmphitheaterSeat; 160 this.aCurrentRoom = vAmphitheaterSeat;
diff --git a/src/esieequest/Room.java b/src/esieequest/Room.java
index 5b4dcfa..780f76a 100644
--- a/src/esieequest/Room.java
+++ b/src/esieequest/Room.java
@@ -1,5 +1,7 @@
1package esieequest; 1package esieequest;
2 2
3import java.util.HashMap;
4
3/** 5/**
4 * A room. 6 * A room.
5 * 7 *
@@ -9,15 +11,18 @@ package esieequest;
9 * @version February 2014 11 * @version February 2014
10 */ 12 */
11public class Room { 13public class Room {
12 private String aDescription;
13 14
14 private Room aNorthExit; 15 private String aDescription;
15 private Room aSouthExit; 16 private HashMap<String, Room> aExits;
16 private Room aEastExit;
17 private Room aWestExit;
18 17
18 /**
19 * Create a room described "description "Initially, it has no exits.
20 * "description" is something like "a kitchen" or "an open courtyard".
21 */
19 public Room(final String pDescription) { 22 public Room(final String pDescription) {
20 this.aDescription = pDescription; 23 this.aDescription = pDescription;
24 this.aExits = new HashMap<String, Room>();
25
21 } 26 }
22 27
23 public String getDescription() { 28 public String getDescription() {
@@ -25,27 +30,23 @@ public class Room {
25 } 30 }
26 31
27 /** 32 /**
28 * Defines the four exits (other rooms) of this room. 33 * Define an exit from this room.
34 *
35 * @param direction
36 * The direction of the exit.
37 * @param neighbor
38 * The room in the given direction.
29 */ 39 */
30 public void setExits(final Room pNorthExit, final Room pWestExit, final Room pSouthExit, final Room pEastExit) { 40 public void setExit(String direction, Room neighbor) {
31 this.aNorthExit = pNorthExit; 41 this.aExits.put(direction, neighbor);
32 this.aSouthExit = pSouthExit;
33 this.aEastExit = pEastExit;
34 this.aWestExit = pWestExit;
35 } 42 }
36 43
44 /**
45 * Return the room that is reached if we go from this room in direction
46 * "direction". If there is no room in that direction, return null.
47 */
37 public Room getExit(String pDirection) { 48 public Room getExit(String pDirection) {
38 switch (pDirection) { 49 return this.aExits.get(pDirection);
39 case "north":
40 return this.aNorthExit;
41 case "south":
42 return this.aSouthExit;
43 case "east":
44 return this.aEastExit;
45 case "west":
46 return this.aWestExit;
47 }
48 return null;
49 } 50 }
50 51
51 /** 52 /**
@@ -56,19 +57,20 @@ public class Room {
56 */ 57 */
57 public String getExitString() { 58 public String getExitString() {
58 String vExitsString = "Available exits:"; 59 String vExitsString = "Available exits:";
59 if (this.aNorthExit != null) { 60 if (this.aExits.get("north") != null) {
60 vExitsString += " North"; 61 vExitsString += " North";
61 } 62 }
62 if (this.aSouthExit != null) { 63 if (this.aExits.get("south") != null) {
63 vExitsString += " South"; 64 vExitsString += " South";
64 } 65 }
65 if (this.aEastExit != null) { 66 if (this.aExits.get("east") != null) {
66 vExitsString += " East"; 67 vExitsString += " East";
67 } 68 }
68 if (this.aWestExit != null) { 69 if (this.aExits.get("west") != null) {
69 vExitsString += " West"; 70 vExitsString += " West";
70 } 71 }
71 vExitsString += "."; 72 vExitsString += ".";
72 return vExitsString; 73 return vExitsString;
73 } 74 }
75
74}