forked from aryanch22/PlanetHoppingGame
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlanetHades.java
More file actions
418 lines (342 loc) · 15 KB
/
PlanetHades.java
File metadata and controls
418 lines (342 loc) · 15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
import java.util.*;
import java.io.*;
/**
* Write a description of class PlanetHades here.
*
* @author (your name)
* @version (a version number or a date)
*/
class PlanetHades implements Planet
{
Assistant dialog = new Assistant();
Alexender Alex_dialog = new Alexender();
DirectionLess less = new DirectionLess();
//Room One begins
class roomOne implements PlanetHades.room.character, PlanetHades.room{
public void readRoomFile() throws Exception{
//The description of room 1
File file = new File("Game\\Planet\\Hades\\Room 1\\A) Describe the room.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
while((st = br.readLine()) != null){
System.out.println(st);
}
br.close();
}
@Override
public void readCharacterFile() throws Exception{
//Assistant dialog for room
dialog.RoomOneDialog();
}
public void North()throws Exception{
//Player goes North
File file = new File("Game\\Planet\\Hades\\Room 1\\North\\North.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
Commands pick = new Commands();
File item = new File("Game\\Planet\\Hades\\Room 1\\Items\\redDiamond\\Description.txt");
BufferedReader red = new BufferedReader(new FileReader(item));
String st, dia;
while((st = br.readLine()) != null){
if(st.contains("[pick up]")){
//copies in entire item name and descritption
while((dia = red.readLine()) != null){
pick.PickUP(dia);
System.out.println(dia);
}
}else{
System.out.println(st);
}
}
br.close();
red.close();
}
public void FirstEast()throws Exception{
// When the player goes east before the explosion
File file = new File("Game\\Planet\\Hades\\Room 1\\FirstEast\\FirstEast.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
while((st = br.readLine()) != null){
System.out.println(st);
}
br.close();
}
public void West()throws Exception{
//When the player goes west
File file = new File("Game\\Planet\\Hades\\Room 1\\West\\West.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
while((st = br.readLine()) != null){
System.out.println(st);
}
br.close();
}
public void South() throws Exception{
//reads an input of the user to either check out the skeleton or not
//the player goes south and puts book in inventory
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
File file = new File("Game\\Planet\\Hades\\Room 1\\South\\South.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
Commands pick = new Commands();
String st;
while((st = br.readLine()) != null){
System.out.println(st);
}
String userInput = reader.readLine();
if(userInput.contains("check")){
File pathSkele = new File("Game\\Planet\\Hades\\Room 1\\South\\Skeleton\\LyingSkeleton.txt");
BufferedReader skele = new BufferedReader(new FileReader(pathSkele));
String text, recite;
//copies in entire item name and descritption
while((text = skele.readLine()) != null){
if(text.contains("[Update inventory with “Book of planet hades”]")){
File item = new File("Game\\Planet\\Hades\\Room 1\\Items\\BookOfHades\\Description.txt");
BufferedReader book = new BufferedReader(new FileReader(item));
while((recite = book.readLine()) != null){
pick.PickUP(recite);
System.out.println(recite);
}
}else{
System.out.println(text);
}
}
}
br.close();
}
public void RunBack() throws Exception{
//player goes back to the first room with Alexender
File file = new File("Game\\Planet\\Hades\\Room 1\\runBack.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st, AlexOffer;
System.out.println("\n");
while((st = br.readLine()) != null){
System.out.println(st);
}
System.out.println("\n");
Alex_dialog.FixingShip();
br.close();
}
public void HandOver() throws Exception{
//When the player hands over the redDiamond to Alexender
File give = new File("Game\\Planet\\Hades\\Room 1\\Character\\Alexender\\HandOverRed.txt");
BufferedReader Alex = new BufferedReader(new FileReader(give));
Commands hand = new Commands();
String removeRed = "Red Diamond";
hand.Give(removeRed);
String goodJob;
goodJob = Alex.readLine();
System.out.println(goodJob);
}
public void SecondEast() throws Exception{
//You head East to Room 3
File file = new File("Game\\Planet\\Hades\\Room 1\\SecondEast\\SecondEast.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
while((st = br.readLine()) != null){
System.out.println(st);
}
br.close();
}
}
//These are the characteristics of room 2
class RoomTwo implements PlanetHades.room.character, room.monster, PlanetHades.room{
//Direction in this room is meaningless since you fight a monster here
public void North()throws Exception{
less.Nothing();
}
public void FirstEast()throws Exception{
less.Nothing();
}
public void West() throws Exception{
less.Nothing();
}
public void South() throws Exception{
less.Nothing();
}
public void readRoomFile() throws Exception{
//Reads the room descritption of Room 2
File file = new File("Game\\Planet\\Hades\\Room 2\\Describe the room.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
System.out.println("\n");
while((st = br.readLine()) != null){
System.out.println(st);
}
br.close();
}
@Override
public void readCharacterFile() throws Exception{
//Alexenders introduction dialog
Alex_dialog.IntroductionAlexender();
}
@Override
public void readMonsterFile() throws Exception{
//The monster lurks in the background
File file = new File("Game\\Planet\\Hades\\Room 2\\Monster\\Action\\Action.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
while((st = br.readLine()) != null){
System.out.println(st);
}
br.close();
}
public void StartBattle() throws Exception{
//second room battle starts
File file = new File("Game\\Planet\\Hades\\Room 2\\Monster\\battle\\startbattle.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
while((st = br.readLine()) != null){
System.out.println(st);
}
br.close();
}
public boolean Attack() throws Exception{
//When the player attacks the Monster
String file = "Game\\Planet\\Hades\\Room 2\\Monster\\NumberOfHit.txt";
Battle enter = new Battle();
return enter.EntityAttack(false, file, false);
}
public boolean MonsterResponse() throws Exception{
//When the monster attacks the player
String playerFile;
playerFile = "Game\\Planet\\Player\\Hits.txt";
Battle enter = new Battle();
return enter.EntityAttack(false,playerFile, true);
}
public void assistant() throws Exception{
//Your companion tells you something is lurking in the background
dialog.RoomTwoDialog();
}
public void Ask(String question) throws Exception{
//Ask about the planet to Alexender
if(question.contains("Ask")){
Alex_dialog.AskAboutPlanet();
}
}
public void Boom() throws Exception{
//At the end of your conversation with Alexender you hear an explosion
File file = new File("Game\\Planet\\Hades\\Room 2\\Character\\PlayerCharacter\\boom.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
while((st = br.readLine()) != null){
System.out.println(st);
}
br.close();
}
public void Run() throws Exception{
//you go back to the first room
File file = new File("Game\\Planet\\Hades\\Room 2\\Character\\Alexander\\AlexanderBoom.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
st = br.readLine();
System.out.println(st);
}
}
//Room three starts here
class RoomThree implements PlanetHades.room.character, PlanetHades.room, PlanetHades.room.monster{
public void readCharacterFile() throws Exception{
//the robot Assistant dialog after going North
dialog.RoomThreeDialog();
}
public void readRoomFile()throws Exception{
//reads room 3 description
File file = new File("Game\\Planet\\Hades\\Room 3\\Describe the room.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
System.out.println("\n");
while((st = br.readLine()) != null){
System.out.println(st);
}
br.close();
}
public void North()throws Exception{
//When the player goes north in the third room
File file = new File("Game\\Planet\\Hades\\Room 3\\North\\North.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
System.out.println("\n");
while((st = br.readLine()) != null){
System.out.println(st);
}
}
public void FirstEast()throws Exception{
//When the player goes East
File file = new File("Game\\Planet\\Hades\\Room 3\\East\\East.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
System.out.println("\n");
while((st = br.readLine()) != null){
System.out.println(st);
}
br.close();
}
public void West() throws Exception{
less.Nothing();
}
public void South() throws Exception{
less.Nothing();
}
public void readMonsterFile() throws Exception{
// before the monster attacks
File file = new File("Game\\Planet\\Hades\\Room 3\\Monster\\Action\\Action.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
while((st = br.readLine()) != null){
System.out.println(st);
}
br.close();
}
public void CaveAttack() throws Exception{
//When monster attacks
File file = new File("Game\\Planet\\Hades\\Room 3\\cave.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
while((st = br.readLine()) != null){
System.out.println(st);
}
br.close();
}
//"A" represents the amount of hits the player or Monster can take
public boolean Attack()throws Exception{
//Battle inside the cave attack by the player
//When the player attacks the monster
String deal;
String file = "Game\\Planet\\Hades\\Room 3\\Monster\\NumberOfHit.txt";
Battle enter = new Battle();
return enter.EntityAttack(true, file, false);
}
public boolean MonsterResponse()throws Exception{
//When the monster attacks the player
String deal;
String playerFile;
playerFile = "Game\\Planet\\Player\\Hits.txt";
Battle enter = new Battle();
return enter.EntityAttack(true,playerFile, true);
}
public void EndOfBattle()throws Exception{
//When the battle ends
File file = new File("Game\\Planet\\Hades\\Room 3\\Character\\PlayerCharacter\\EndOfBattle.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
System.out.println("\n");
while((st = br.readLine()) != null){
System.out.println(st);
}
br.close();
}
public void Alex() throws Exception{
//Alexender shows up again after the battle
Alex_dialog.EndPlanetDialog();
}
public void EndPlanet() throws Exception{
//The end of the planet
File file = new File("Game\\Planet\\Hades\\Room 3\\Character\\PlayerCharacter\\End.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
System.out.println("\n");
while((st = br.readLine()) != null){
System.out.println(st);
}
br.close();
}
}
}