diff options
Diffstat (limited to 'src/esieequest/model/Game.java')
-rw-r--r-- | src/esieequest/model/Game.java | 223 |
1 files changed, 223 insertions, 0 deletions
diff --git a/src/esieequest/model/Game.java b/src/esieequest/model/Game.java new file mode 100644 index 0000000..ed7c3df --- /dev/null +++ b/src/esieequest/model/Game.java | |||
@@ -0,0 +1,223 @@ | |||
1 | package esieequest.model; | ||
2 | |||
3 | import java.util.Observable; | ||
4 | import java.util.HashMap; | ||
5 | |||
6 | /** | ||
7 | * | ||
8 | * @author Pacien TRAN-GIRARD | ||
9 | * @author Benoit LUBRANO DI SBARAGLIONE | ||
10 | * | ||
11 | * @version February 2014 | ||
12 | */ | ||
13 | public class Game extends Observable { | ||
14 | |||
15 | private boolean aRunning; | ||
16 | private HashMap<String, Room> aRooms; | ||
17 | private Room aCurrentRoom; | ||
18 | |||
19 | public Game() { | ||
20 | this.aRunning = false; | ||
21 | this.aRooms = new HashMap<String, Room>(); | ||
22 | this.aCurrentRoom = null; | ||
23 | |||
24 | this.createRooms(); | ||
25 | this.linkRooms(); | ||
26 | this.goToRoom("AmphitheaterSeat"); | ||
27 | } | ||
28 | |||
29 | private void createRoom(final String pName, final String pDescription) { | ||
30 | this.aRooms.put(pName, new Room(pDescription)); | ||
31 | } | ||
32 | |||
33 | private void setRoomExit(final String pRoomName, final String pDirection, | ||
34 | final String pExitRoomName) { | ||
35 | this.aRooms.get(pRoomName).setExit(pDirection, this.aRooms.get(pExitRoomName)); | ||
36 | } | ||
37 | |||
38 | private void createRooms() { | ||
39 | this.createRoom("AmphitheaterSeat", "in the amphitheater"); | ||
40 | this.createRoom("AmphitheaterStage", "on the amphitheater stage"); | ||
41 | |||
42 | this.createRoom("CafeteriaStreet", "in the main corridor, in front of the cafeteria"); | ||
43 | this.createRoom("Cafeteria", "at the cafeteria"); | ||
44 | |||
45 | this.createRoom("EsieespaceStreet", "in the main corridor, in front of the ESIEEspace HQ"); | ||
46 | this.createRoom("EsieespaceFront", "in front of the ESIEEspace HQ"); | ||
47 | this.createRoom("EsieespaceEntrance", "at the ESIEEspace HQ entrance"); | ||
48 | this.createRoom("Esieespace", "in the ESIEEspace HQ"); | ||
49 | |||
50 | this.createRoom("ClubnixStreet", "in the main corridor, in front of the Club*Nix"); | ||
51 | this.createRoom("ClubnixFront", "in front of the Club*Nix"); | ||
52 | this.createRoom("ClubnixEntrance", "at the Club*Nix entrance"); | ||
53 | this.createRoom("Clubnix", "in the Club*Nix"); | ||
54 | |||
55 | this.createRoom("EntranceStreet", "in the main corridor, at the reception"); | ||
56 | this.createRoom("EntranceStairs", "on the main entrance stairs"); | ||
57 | this.createRoom("EntranceRoundabout", "on the roundabout"); | ||
58 | |||
59 | this.createRoom("WingStreet", "in font of wing #3"); | ||
60 | this.createRoom("WingCorridorOne", "in the corridor in wing #3, on the ground floor"); | ||
61 | this.createRoom("WingStairsOne", "in the stairwell on the ground floor"); | ||
62 | this.createRoom("WingStairsTwo", "in the stairwell on the first floor"); | ||
63 | this.createRoom("WingCorridorTwo", "in the corridor in wind #3, on the first floor"); | ||
64 | this.createRoom("WingCorridorTwoOffice", "in front of the office #3254"); | ||
65 | this.createRoom("WingOffice", "in the office #3254"); | ||
66 | |||
67 | this.createRoom("OffscriptEat", "somewhere implementing hunger"); | ||
68 | this.createRoom("OffscriptEatPantry", "in the pantry"); | ||
69 | this.createRoom("OffscriptTake", "somewhere implementing weight"); | ||
70 | this.createRoom("OffscriptTakeStorageroom", "in a storage room"); | ||
71 | this.createRoom("OffscriptTimeout", "somewhere implementing time"); | ||
72 | this.createRoom("OffscriptTimeoutCountdownroom", "in a dangerous room"); | ||
73 | this.createRoom("OffscriptTrapdoor", "somewhere implementing a trap"); | ||
74 | this.createRoom("OffscriptTrapdoorDeadend", "trapped"); | ||
75 | this.createRoom("OffscriptBeamer", "somewhere implementing teleportation"); | ||
76 | this.createRoom("OffscriptBeamerAnchor", "on a checkpoint"); | ||
77 | this.createRoom("OffscriptLock", "somewhere implementing a doorlock"); | ||
78 | this.createRoom("OffscriptLockLockedroom", "in a locked room that is not anymore"); | ||
79 | this.createRoom("OffscriptAlea", "somewhere implementing alea"); | ||
80 | this.createRoom("OffscriptAleaRoomrandomizer", | ||
81 | "in a weird room that will transport you somewhere else"); | ||
82 | this.createRoom("OffscriptMovingcharacter", "somewhere implementing a moving character"); | ||
83 | this.createRoom("OffscriptMovingcharacterMo", "in M-O's room"); | ||
84 | |||
85 | } | ||
86 | |||
87 | private void linkRooms() { | ||
88 | this.setRoomExit("AmphitheaterSeat", "north", "AmphitheaterStage"); | ||
89 | this.setRoomExit("AmphitheaterStage", "west", "Cafeteria"); | ||
90 | |||
91 | this.setRoomExit("CafeteriaStreet", "south", "Cafeteria"); | ||
92 | this.setRoomExit("CafeteriaStreet", "east", "EsieespaceStreet"); | ||
93 | this.setRoomExit("Cafeteria", "north", "CafeteriaStreet"); | ||
94 | this.setRoomExit("Cafeteria", "east", "AmphitheaterStage"); | ||
95 | |||
96 | this.setRoomExit("EsieespaceStreet", "west", "Cafeteria"); | ||
97 | this.setRoomExit("EsieespaceStreet", "south", "EsieespaceFront"); | ||
98 | this.setRoomExit("EsieespaceStreet", "east", "EntranceStreet"); | ||
99 | this.setRoomExit("EsieespaceFront", "north", "EsieespaceStreet"); | ||
100 | this.setRoomExit("EsieespaceFront", "east", "EsieespaceEntrance"); | ||
101 | this.setRoomExit("EsieespaceEntrance", "north", "Esieespace"); | ||
102 | this.setRoomExit("EsieespaceEntrance", "west", "EsieespaceFront"); | ||
103 | this.setRoomExit("Esieespace", "south", "EsieespaceEntrance"); | ||
104 | |||
105 | this.setRoomExit("ClubnixStreet", "west", "WingStreet"); | ||
106 | this.setRoomExit("ClubnixStreet", "south", "ClubnixFront"); | ||
107 | this.setRoomExit("ClubnixFront", "north", "ClubnixStreet"); | ||
108 | this.setRoomExit("ClubnixFront", "east", "ClubnixEntrance"); | ||
109 | this.setRoomExit("ClubnixEntrance", "north", "Clubnix"); | ||
110 | this.setRoomExit("ClubnixEntrance", "west", "ClubnixFront"); | ||
111 | this.setRoomExit("Clubnix", "south", "ClubnixEntrance"); | ||
112 | |||
113 | this.setRoomExit("EntranceStreet", "west", "EsieespaceStreet"); | ||
114 | this.setRoomExit("EntranceStreet", "south", "EntranceStairs"); | ||
115 | this.setRoomExit("EntranceStreet", "east", "WingStreet"); | ||
116 | this.setRoomExit("EntranceStairs", "north", "EntranceStreet"); | ||
117 | this.setRoomExit("EntranceStairs", "south", "EntranceRoundabout"); | ||
118 | this.setRoomExit("EntranceRoundabout", "north", "EntranceStairs"); | ||
119 | |||
120 | this.setRoomExit("WingStreet", "north", "WingCorridorOne"); | ||
121 | this.setRoomExit("WingStreet", "west", "EntranceStreet"); | ||
122 | this.setRoomExit("WingStreet", "east", "ClubnixStreet"); | ||
123 | this.setRoomExit("WingCorridorOne", "west", "WingStairsOne"); | ||
124 | this.setRoomExit("WingCorridorOne", "south", "WingStreet"); | ||
125 | this.setRoomExit("WingCorridorOne", "east", "OffscriptEat"); | ||
126 | this.setRoomExit("WingStairsOne", "south", "WingStairsTwo"); | ||
127 | this.setRoomExit("WingStairsOne", "up", "WingStairsTwo"); | ||
128 | this.setRoomExit("WingStairsOne", "east", "WingCorridorOne"); | ||
129 | this.setRoomExit("WingStairsTwo", "south", "WingStairsOne"); | ||
130 | this.setRoomExit("WingStairsTwo", "down", "WingStairsOne"); | ||
131 | this.setRoomExit("WingStairsTwo", "east", "WingCorridorTwo"); | ||
132 | this.setRoomExit("WingCorridorTwo", "north", "WingCorridorTwoOffice"); | ||
133 | this.setRoomExit("WingCorridorTwoOffice", "south", "WingCorridorTwo"); | ||
134 | this.setRoomExit("WingCorridorTwoOffice", "east", "WingOffice"); | ||
135 | this.setRoomExit("WingOffice", "west", "WingCorridorTwoOffice"); | ||
136 | |||
137 | this.setRoomExit("OffscriptEat", "north", "OffscriptEatPantry"); | ||
138 | this.setRoomExit("OffscriptEat", "west", "WingCorridorOne"); | ||
139 | this.setRoomExit("OffscriptEat", "east", "OffscriptTake"); | ||
140 | this.setRoomExit("OffscriptEatPantry", "south", "OffscriptEat"); | ||
141 | this.setRoomExit("OffscriptTake", "north", "OffscriptTakeStorageroom"); | ||
142 | this.setRoomExit("OffscriptTake", "west", "OffscriptEat"); | ||
143 | this.setRoomExit("OffscriptTake", "east", "OffscriptTimeout"); | ||
144 | this.setRoomExit("OffscriptTakeStorageroom", "south", "OffscriptTake"); | ||
145 | this.setRoomExit("OffscriptTimeout", "north", "OffscriptTimeoutCountdownroom"); | ||
146 | this.setRoomExit("OffscriptTimeout", "west", "OffscriptTakeStorageroom"); | ||
147 | this.setRoomExit("OffscriptTimeout", "east", "OffscriptTrapdoor"); | ||
148 | this.setRoomExit("OffscriptTimeoutCountdownroom", "south", "OffscriptTimeout"); | ||
149 | this.setRoomExit("OffscriptTrapdoor", "north", "OffscriptTrapdoorDeadend"); | ||
150 | this.setRoomExit("OffscriptTrapdoor", "west", "OffscriptTimeout"); | ||
151 | this.setRoomExit("OffscriptTrapdoor", "east", "OffscriptBeamer"); | ||
152 | this.setRoomExit("OffscriptTrapdoorDeadend", "south", "OffscriptTrapdoor"); | ||
153 | this.setRoomExit("OffscriptBeamer", "north", "OffscriptBeamerAnchor"); | ||
154 | this.setRoomExit("OffscriptBeamer", "west", "OffscriptTrapdoor"); | ||
155 | this.setRoomExit("OffscriptBeamer", "east", "OffscriptLock"); | ||
156 | this.setRoomExit("OffscriptBeamerAnchor", "south", "OffscriptBeamer"); | ||
157 | this.setRoomExit("OffscriptLock", "north", "OffscriptLockLockedroom"); | ||
158 | this.setRoomExit("OffscriptLock", "west", "OffscriptBeamer"); | ||
159 | this.setRoomExit("OffscriptLock", "east", "OffscriptAlea"); | ||
160 | this.setRoomExit("OffscriptLockLockedroom", "south", "OffscriptLock"); | ||
161 | this.setRoomExit("OffscriptAlea", "north", "OffscriptAleaRoomrandomizer"); | ||
162 | this.setRoomExit("OffscriptAlea", "west", "OffscriptLock"); | ||
163 | this.setRoomExit("OffscriptAlea", "east", "OffscriptMovingcharacter"); | ||
164 | this.setRoomExit("OffscriptAleaRoomrandomizer", "south", "OffscriptAlea"); | ||
165 | this.setRoomExit("OffscriptMovingcharacter", "north", "OffscriptMovingcharacterMo"); | ||
166 | this.setRoomExit("OffscriptMovingcharacter", "west", "OffscriptAlea"); | ||
167 | } | ||
168 | |||
169 | public void setRunning(final boolean pState) { | ||
170 | this.aRunning = pState; | ||
171 | this.setChanged(); | ||
172 | this.notifyObservers("state"); | ||
173 | } | ||
174 | |||
175 | public boolean isRunning() { | ||
176 | return this.aRunning; | ||
177 | } | ||
178 | |||
179 | public void goToRoom(final Room pRoom) { | ||
180 | this.aCurrentRoom = pRoom; | ||
181 | this.setChanged(); | ||
182 | this.notifyObservers("room"); | ||
183 | } | ||
184 | |||
185 | public void goToRoom(final String pRoomName) { | ||
186 | this.aCurrentRoom = this.aRooms.get(pRoomName); | ||
187 | this.setChanged(); | ||
188 | this.notifyObservers("room"); | ||
189 | } | ||
190 | |||
191 | public Room getRoomExit(final String pDirection) { | ||
192 | return this.aCurrentRoom.getExit(pDirection); | ||
193 | } | ||
194 | |||
195 | public String getLocationInfo() { | ||
196 | return this.aCurrentRoom.getLongDescription(); | ||
197 | } | ||
198 | |||
199 | public String getLocationImageName() { | ||
200 | return this.aCurrentRoom.getImageName(); | ||
201 | } | ||
202 | |||
203 | public String getEatMessage() { | ||
204 | return "oNommNommNomm..."; | ||
205 | } | ||
206 | |||
207 | public String getWelcomeMessage() { | ||
208 | return "Welcome to ESIEEquest! ESIEEquest is a new, amazingly boring adventure game."; | ||
209 | } | ||
210 | |||
211 | public String getHelpMessage() { | ||
212 | return "Everybody else disappeared. You are alone. You wander around at the ESIEE."; | ||
213 | } | ||
214 | |||
215 | public String getQuitMessage() { | ||
216 | return "Thank you for wasting your time. Good bye."; | ||
217 | } | ||