-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDRWHOPassengers.py
435 lines (398 loc) · 16.1 KB
/
DRWHOPassengers.py
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
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
import time
# Rooms
teleport_species = 0
return_ship = 0
class Room(object):
""" Rooms """
def __init__(self,name,item):
self.name = name
self.item = item
def room_map_blank():
print(
"""
--------------
| |
|---| |---| : Security Door
| |
|------------| |
| : |
----- ---------
| |
-----
""" )
def ship_knowledge():
print(
"""
Ship: PROCYON #59.
Captain: Oghathi.
Mission: Collect and catalogue all known intelligent species.
Replications are deleted
Year began: 5804.
Completion: 38%.
""")
# Room (name, item)
cargo = Room("Cargo Hold",["Sonic Screwdriver"])
corr1 = Room("Corridor #1","none")
engine = Room("Engine Room","Tardis")
console = Room("Console Room",["Console"])
corr2 = Room("Corridor #2",["Map"])
security = Room("Security",["Guard"])
corr3 = Room("Corridor #3","Door East")
corr4 = Room("Corridor #4","Door West")
control = Room("Control Room",["Control Panel"])
passenger = Room ("Passenger Room",["Pods"])
teleport = Room ("Teleportation Room",["Teleporters"])
# Room coordinates [n,e,s,w]
cargo.coordinates = [0,corr1,0,0]
corr1.coordinates = [0,engine,corr2,cargo]
engine.coordinates = [0,0,0,corr1]
console.coordinates = [0,corr2,0,0]
corr2.coordinates = [corr1,security,0,console]
security.coordinates = [0,0,control,corr2]
corr3.coordinates = [0,corr4,teleport,passenger]
corr4.coordinates = [0,control,0,corr3]
control.coordinates = [security,0,0,corr4]
passenger.coordinates = [0, corr3, 0, 0]
teleport.coordinates = [corr3, 0, 0, 0]
# Items and Barriers
class Items(object):
def __init__(self, name):
self.name = name
def get_sonic_screwdriver(self):
input("You hear the familiar buzz of your Sonic Screwdriver\
\ncoming from the crates nearby. You begin to search\
\nthrough them. You find it in a box labelled 'TO BE\
\nARCHIVED'. It must have been taken from Clara.")
doctor.inv.append("Sonic Screwdriver")
self.location.item.remove("Sonic Screwdriver")
input("\nSonic Screwdriver has been added to your inventory.")
def see_tardis(self):
print("You can barely see the Tardis hidden amongst the engines.")
def use_console(self):
print("You log on to a console.")
time.sleep(1.5)
print("...")
print("PROCYON #59.")
time.sleep(1.5)
print("CAPTAIN: Oghathi.")
time.sleep(1.5)
print("PROCYON MISSION:")
time.sleep(1.5)
print("Collect and catalogue all known intelligent species.")
time.sleep(1.5)
print("Delete all replications")
time.sleep(1.5)
print("YEAR OF COMMENCEMENT: 5804.")
time.sleep(1.5)
print("COMPLETE: 38%.")
time.sleep(1.5)
input("...")
time.sleep(1.5)
print("You log off the console.")
if "Knowledge" not in doctor.inv:
doctor.inv.append("Knowledge")
input("\nKnowledge has been added to your inventory.")
else:
pass
def use_teleporters(self):
global teleport_species
if "Clara" in doctor.inv and teleport_species == 0:
teleport_species = 1
print("Hundreds of species crowd onto the teleportation grid.")
input("You key in the controls and set it to the nearest planet.")
time.sleep(1)
print("...")
time.sleep(2)
input("The teleportation is successful.")
print("\nCLARA: 'Let's get back to the Tardis'")
print("DOCTOR: 'We need to head to Main Control first'")
else:
print("Nobody to teleport.")
def use_control_panel(self):
global return_ship
if "Clara" in doctor.inv and teleport_species == 1 and return_ship == 0:
return_ship = 1
input("You boot up the main controls and disable the teleporter.\
\nYou set the ship to return to its planet of origin\
\nYou send a message to the rest of the fleet: BEWARE:\
\nTHE DOCTOR IS WATCHING.'")
print("\nDOCTOR: Quick! Let's get back to the Tardis")
else:
print("You have no reason to use the Main Control console.")
def room_map(self):
print("You see a map on the wall in front of you.")
room_map_blank()
input("You memorize the map.")
doctor.inv.append("Map")
self.location.item.remove("Map")
input("\nMap has been added to your inventory.")
def guard_block(self):
print("A guard is blocking your path to the South")
print("GUARD: Only those with clearance shall pass")
doctor.location.coordinates = [0, 0, 0, corr2]
def pods_block(self):
print("You see Clara suspended in a Stasis Pod.")
print("She is unconscious but her vital signs are stable.")
def door_block_west(self):
passcode = "5804" or "5 8 0 4"
print("A door blocks your path.")
passcode_correct = input("ENTER 4 DIGIT PASSCODE: ")
time.sleep(1)
print("...")
time.sleep(1)
if passcode_correct == passcode:
input("ACCESS GRANTED ")
print("You go through the door.")
doctor.location = corr3
doctor.room_descrip()
else:
doctor.location = corr4
doctor.location.coordinates = [0, control, 0, 0]
print("ACCESS DENIED ")
def door_block_east(self):
passcode = "5804" or "5 8 0 4"
print("A door blocks your path")
passcode_correct = input("ENTER 4 DIGIT PASSCODE: ")
time.sleep(1)
print("...")
time.sleep(1)
if passcode_correct == passcode:
input("ACCESS GRANTED ")
print("You go through the door.")
doctor.location = corr4
doctor.room_descrip()
else:
doctor.location = corr3
doctor.location.coordinates = [0, 0, teleport, passenger]
print("ACCESS DENIED ")
# Character
class Character(object):
def __init__(self,name,location,inv):
self.name = name
self.location = location
self.inv = inv
def room_descrip(self):
if self.location.name == "Cargo Hold":
print("You are in a large room. It looks like a cargo hold.")
print("There are crates piled from floor to ceiling.")
elif self.location.name == "Corridor #1":
print("You are in a metallic grey corridor.")
elif self.location.name == "Engine Room":
print("You are in an engine room.")
print("The Tardis is well hidden here.")
elif self.location.name == "Console Room":
print("You are in a small room.")
print("There are 3 consoles in the middle.")
elif self.location.name == "Corridor #2":
print("Two corridors join together.")
print("From here you can travel any direction but South.")
elif self.location.name == "Security":
print("You are in a security room.")
if self.location.item == ["Guard"]:
Items.guard_block(object)
else:
pass
elif self.location.name == "Corridor #3":
print("You are in a metallic grey corridor.")
elif self.location.name == "Corridor #4":
print("You are in a metallic grey corridor.")
elif self.location.name == "Control Room":
print("You are in a room marked 'Main Control'.")
elif self.location.name == "Passenger Room":
if "Clara" not in doctor.inv:
print("You are in a room marked 'PASSENGERS' You see row after\
\nrow of Stasis Pods. Inside each one is a different species.\
\nSilurians, Menoptera, Ood, Argolins, Hath... All catalogued\
\nlike objects in a museum.")
else:
print("You see rows of empty Stasis Pods")
elif self.location.name == "Teleportation Room":
print("This room has a large teleportation grid.")
print("It is designed to teleport masses of people at once.")
print("'Fish tangled in a net' you think to yourself")
else:
pass
def look(self):
if self.location.item == ["Sonic Screwdriver"]:
Items.get_sonic_screwdriver(self)
elif self.location.item == "Tardis":
Items.see_tardis(self)
elif self.location.item == ["Console"]:
Items.use_console(self)
elif self.location.item == ["Pods"]:
Items.pods_block(self)
elif self.location.item == ["Map"]:
Items.room_map(self)
elif self.location.item == ["Control Panel"]:
Items.use_control_panel(self)
elif self.location.item == ["Teleporters"]:
Items.use_teleporters(self)
elif self.location.item == "Door West":
print("There is a door blocking your path to the west.")
elif self.location.item == "Door East":
print("There is a door blocking your path to the east.")
elif self.location.item == "none":
print ("There is nothing of interest here.")
else:
print("There is nothing of interest here.")
def inventory(self):
print("You are carrying: ")
for item in doctor.inv:
print(item)
doctor = Character("The Doctor", engine,["Tardis Key", "Psychic Paper"])
print ("\t\tDOCTOR WHO: PASSENGERS")
print ("\t\tA Text Based Adventure\n\n")
input ("Clara has been kidnapped. Fortunately, she was carrying\
\nyour Sonic Screwdriver. You have locked on to the signal\
\nand have landed nearby. It is up to you to rescue Clara\
\nand escape in the Tardis.")
time.sleep(1)
#help
def help_function():
print("""
~~~~~~~~~~~~~~~~~~~
""")
print ("\t\tGAME COMMANDS")
print ("\n"'"n","e","s", and "w" to move.')
print ('"look" to look around the room.')
print ('"inv" to see your inventory.')
print ('"use <item>" to use an item or object.')
print ('"end" to quit the game. All progress will be lost.')
print ('"help" to see this list again.')
# Main Game Loop
help_function()
input("\nPress enter to begin ")
time.sleep(1)
print("""
~~~~~~~~~~~~~~~~~~~
""")
doctor.room_descrip()
while True:
command = input("\n>>> ")
command = command.lower()
if command == "look":
doctor.look()
if command == "inv":
doctor.inventory()
if command == "use psychic paper":
if "Psychic Paper" in doctor.inv:
if doctor.location == security and doctor.location.item == ["Guard"]:
doctor.location.item.remove("Guard")
time.sleep(1)
print("GUARD: Level 5 Clearance granted. You may pass.")
doctor.location.coordinates = [0, 0, control, corr2]
else:
print("It had no effect")
else:
pass
if command == "use sonic screwdriver":
if "Sonic Screwdriver" in doctor.inv:
if doctor.location == passenger and doctor.location.item == ["Pods"]:
doctor.location.item.remove("Pods")
time.sleep(1)
print("A buzzer sounds and the Stasis doors open. The 'passengers'\
\nbegin to regain consciousness. You tell them to head to the\
\nTeleportation Room. You help Clara up and out of her Pod.")
doctor.inv.append("Clara")
else:
print("It had no effect.")
else:
print("You do not have your Sonic Screwdriver.")
if command == "use tardis key":
if doctor.location == engine:
if "Clara" in doctor.inv and teleport_species == 1 and return_ship == 1:
time.sleep(1)
print("VWOOORRRP...")
time.sleep(2)
print("VWOOOOORRRRRRP...")
time.sleep(2)
print("VWOOOOOOORRRRRRRRP...")
time.sleep(2)
print("The Tardis fades out of the room.")
input("The Doctor and Clara have escaped.")
print("\nI hope you have enjoyed the adventure.\
\nThanks for playing.\n")
break
elif "Clara" in doctor.inv and teleport_species == 1 and return_ship == 0:
print("You need to send a message first.")
print("Head to the Main Control room")
elif "Clara" in doctor.inv and teleport_species == 1 and return_ship == 0:
print("You need to save the other species")
print("Head to the teleportation room")
elif "Clara" in doctor.inv and teleport_species == 0 and return_ship == 0:
print("You need to save the other species")
print("Head to the teleportation room")
elif "Clara" not in doctor.inv:
print("You can't leave without Clara")
else:
print("The Tardis is not in this room.")
if command == "use console":
if doctor.location == console:
Items.use_console(object)
else:
pass
if command == "use main control":
if doctor.location == control:
Items.use_control_panel(object)
else:
pass
if command == "use teleporter":
if doctor.location == teleport:
Items.use_teleporters(object)
else:
pass
if command == ("n" or "north"):
if doctor.location.coordinates[0] == 0:
print ("You cannot go that way.")
else:
doctor.location = doctor.location.coordinates[0]
doctor.room_descrip()
if command == ("e" or "east"):
if doctor.location == corr3:
Items.door_block_east(object)
elif doctor.location.coordinates[1] == 0:
print ("You cannot go that way.")
else:
doctor.location = doctor.location.coordinates[1]
doctor.room_descrip()
if command == ("s" or "south"):
if doctor.location.coordinates[2] == 0:
print ("You cannot go that way.")
else:
doctor.location = doctor.location.coordinates[2]
doctor.room_descrip()
if command == ("w" or "west"):
if doctor.location == corr4:
Items.door_block_west(object)
elif doctor.location.coordinates[3] == 0:
print ("You cannot go that way.")
else:
doctor.location = doctor.location.coordinates[3]
doctor.room_descrip()
if command == ("help"):
help_function()
if command == ("use map"):
if "Map" in doctor.inv:
room_map_blank()
if command == ("use knowledge"):
if "Knowledge" in doctor.inv:
ship_knowledge()
else:
print("You do not have that information.")
if command == "end":
break
input("Press enter to exit")
# end
# ++++ Room Map +++++
# 1. cargo
# =================== 2. corr1
# -------------- 3. engine
# | 1 2 3 | 4. console
# |---| |---| 5. corr2
# | 4 5 6 | 6. security
# |------------| | 7. passenger
# | 7 8 9 10 | 8. corr3
# ----- --------- 9. corr4
# | 11 | 10. control
# ----- 11. teleport
# ===================