-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rooms.py
251 lines (201 loc) · 11.3 KB
/
Rooms.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
import time
import random
global safe_number
def random_safe_code():
global safe_number
# use the randrange function from random library, make sure it'll always
# be a 6 digit number
safe_number = random.randrange(100000, 999999)
return safe_number
random_safe_code()
class FrontDoor:
name = 'front_door'
description = 'The front door is a massive plank of dark oak, with a large golden handle.'
actions = ['Try the front door.', 'Look up the stairs.', 'Hide inside the coat closet']
action_results = ['The door is locked shut.', "Darkness...you hear faint footsteps on one of the upper floors. You're not alone.", 'You are hidden. You also find a spare tuxedo hanging in the closet, obviously the person who lived here liked to play football.']
action_completed = [False, False, False]
# only way to win the game so far, could be other ways if we want
def escape_the_house(self, has_escape_keys):
answer = input("Do you try to escape through the front door? (y/n)").upper()
if answer == "Y":
if has_escape_keys:
print("You open the front door and escape this creepy house. YOU WIN!!")
quit()
else:
print("You need the correct key to open this door. Go search the house, you may get lucky.")
return False
elif answer == "N":
print("Well, at least you didn't waste your time.")
return False
else:
print("Not a valid response. Try again.")
self.escape_the_house(has_escape_keys)
class DiningRoom:
global safe_number
name = 'dining_room'
description = """
A long table sits at the center of the dining room, perfectly
set with pristine china. A large chandelier floats above it,
candlelight illuminating the small room with a warm glow.
"""
actions = ['Sit at the table.', 'Hide under the table.', 'Inspect the chandelier.']
action_results = ['The seat is warm. Suddenly you feel that someone is watching you.', f"The table cloth conseales you... You see a number carved into the underside of the table. '{safe_number}'", 'Whoever lives here needs to dust more often.']
action_completed = [False, False, False]
def specialInteraction(self):
return 'If there is a special interaction it goes here.'
class LivingRoom:
global safe_number
name = 'living_room'
description = """
Surprisingly, the living room seems well kept. Eveything is in
its right place. A large painting is hung on the wall. A
painting of some man, looks familiar from somewhere...
"""
actions = ['Lift the painting', 'Sit on the lounge sofa', 'Inspect the painting']
action_results = ['You lift the painting to find some sort of safe behind it. If only you had the combination...', 'Creeek! Sitting on the sofa causes a loud noise.', 'You see initials on the bottom left of the painting: A.A. Probably the persons initials?']
action_completed = [False, False, False]
def open_safe(self):
user_choice = input("Do you attempt to open the safe? (y/n) ").upper()
if user_choice == 'Y':
while True:
try:
user_code = int(input("Enter the safe code: "))
break
except ValueError:
print('Please enter an integer value.')
if user_code == safe_number:
print("You have opened the safe!! Inside you find a set of keys. These could be useful.")
return True
else:
print("That is not the correct safe code. You could try again.\n")
self.open_safe()
elif user_choice == 'N':
print("There's no way I can open it without the combination.")
return False
class Kitchen:
name = 'kitchen'
description = """
You try to turn on the light but it doesn't work, maybe that's
for the better. Still, the kitchen has a strange odor to it,
and some dishes in the sink.
"""
actions = ['Check inside the fridge.', 'Look inside the cabinet.', 'Open the drawer next to the sink.']
action_results = ['A putrid stench emits from the fridge, and you notice a cloudy jar on the top shelf.', 'Nothing special in here.', 'You find a sheathed knife lying in the drawer. It has some Asain writing on it.']
action_completed = [False, False, False]
@staticmethod
def inspect_jar():
user_choice = input("Do you wish to open the jar? (y/n) ").upper()
if user_choice == 'Y':
print("You open the jar to find some kind of egg inside. Who knows how long this has been here?")
elif user_choice == 'N':
print("Perhaps that was a wise choice. Stay safe.")
@staticmethod
def take_knife():
user_choice = input("Do you take the knife? (y/n) ").upper()
if user_choice == 'Y':
print("The knife is pretty lightweight. This writing obviously means something, but I wonder what. You keep a hold of the knife just in case.")
return True
elif user_choice == 'N':
print("Better leave it. Don't wanna hurt myself.")
return False
class Bathroom:
name = 'bathroom'
description = 'The bathroom is small. Not a pleasant smell at all, and the light flickers for a while before fully turning on.'
actions = ['Flush the toilet.', 'Open the medicine cabinet.', 'Pull back the shower curtain.']
action_results = ['It seems broken...I guess the smell is staying.', 'A lot of painkillers...and fungicide, fungus???', 'It is as you feared, a small pool of blood remains in the tub.']
action_completed = [False, False, False]
def specialInteraction(self):
return 'If there is a special interaction it goes here.'
class Bedroom:
global in_room
name = 'bedroom'
description = 'A very simple looking bedroom. Signs of use appear throughout the room. But where is the resident?'
actions = ['Look in the Closet', 'Search the Nightstand', 'Look in the mirror']
action_results = ["It's not a closet at all, but a secret passageway leading up somewhere...", 'Fitting, you find a copy of The Shining.', 'You see a figure pass by the door behind you...is it too late to leave?']
action_completed = [False, False, False]
def go_up_passage(self, has_keys):
print("You go up the secret passageway. At the end is a door...but it's locked. You need a key to enter.")
user_choice = input("Do you try to open the door? (y/n) ").upper()
if user_choice == 'Y':
if has_keys:
in_room = False
# just had to add it here for dramatic effect
time.sleep(2)
print("You take a second to find the right key but once you do the door clicks open...and you step through the threshold...")
return True
# this will lead into the second floor of rooms
else:
print("You need a key to open this door. Find the keys and come back again.")
elif user_choice == 'N':
print("Be on your way, but don't waste any time!")
return False
@staticmethod
def open_book():
print("On the inside cover you see the writing: Property of A.A. Hmmm, this must be the owner of the house. If only I could remember who has those initials.")
class Library:
name = 'library'
description = """
After walking through the door, you see a welcome sight.
Shelves of books. This looks like a true treasure trove. An
armchair sits next to a fireplace with a fancy globe in the corner.
"""
actions = ['Inspect the large globe', 'Browse through the books', 'Inspect the fireplace']
action_results = ['The globe opens up and inside are a bunch of pictures of violas.', 'Whoever lives here has good taste, now that I mention it, what happened to the steps I heard from up here? Maybe I should hide somwhere...', "This fireplace looks recently extinguished, I've really got to find a way out of this house..."]
action_completed = [False, False, False]
def hide_in_shadows(self):
user_input = input("Do you hide in the shadows? (y/n)").upper()
if user_input == "Y":
print("You are hidden. You accidently knock down a book from the shelf...a thud breaks the silence.")
return True
elif user_input == "N":
print("Feeling lucky today are we? Well, beware of danger.")
else:
print("Not a valid input. Try again.")
self.hide_in_shadows()
class Study:
name = 'study'
description = """
The study is quite small but messy. There is a main desk and
there are lots of loose papers lying around as well as an
important looking envelope. This room
should provide some useful information.
"""
actions = ['Open the envelope', 'Look through the desk drawer', 'Hide under the desk']
action_results = ["Inside is a letter.", 'You find a another set of keys, maybe these will help you escape?', 'You scramble under the desk, holding your breath. You could have sworn you heard footsteps in the library.']
action_completed = [False, False, False]
def read_letter(self):
answer = input("Do you read the letter? (y/n)").upper()
if answer == "Y":
print("""
If you're reading this...I don't have much time. I'm hiding in the bathtub right now and that...thing, I hear it walking around the kitchen. It's looking for me.
Great Scott, forgive me!! I didn't mean for this to happen! I just wanted to prank the kid, get a good laugh. My friends told me this house was abandoned!
Whatever that thing is, it just slipped from the shadows and took him...and the screams...I didn't know a child could make those noises.
I barely had enough time to make a dash for the bathroom. But it knows I'm here. It's only a matter of time before it finds me...and does to me what it did to that kid!
If you find this note, please, just tell the Constanzas I'm sorry. I never wanted this to happen. I'm sorry Georgie. You were a good kid and now you're dead.
Oh God. I think it found me. Mom dad I'm so sorry please no I don't wan-
""")
print("It's time to go.")
elif answer == "N":
print("You don't need help, you've got all you need inside your head.")
else:
print("Not a valid answer, try again.")
self.read_letter()
def take_keys(self):
answer = input("Do you take the keys? (y/n)").upper()
if answer == "Y":
return True
elif answer == "N":
print("You sure like to take risks, don't you??")
return False
else:
print("Not a valid answer. Try again.")
self.take_keys()
front_door = FrontDoor()
dining_room = DiningRoom()
living_room = LivingRoom()
kitchen = Kitchen()
bathroom = Bathroom()
bedroom = Bedroom()
library = Library()
study = Study()
all_rooms = [front_door, dining_room, living_room, kitchen, bathroom, bedroom, library, study]