-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroom_main.py
238 lines (166 loc) Β· 6.66 KB
/
room_main.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
from room_classes import Room
from room_character import Enemy, Friend
from room_item import Cheese, Potions
#Variables so I don't have to write those lines everytime
which_direction = "\n β Which direction would you like to go? North? β South? β East? β West? β"
nothing = "\n....There's nothing in here. You should try to go somewhere else.\n"
#Create (=instantiate) rooms and their attributes
kitchen = Room("KITCHEN π₯£")
kitchen.set_description("it's a dank and dirty room, buzzing with flies.")
ballroom = Room("BALLROOM π")
ballroom.set_description("you feel like a princess.")
dining_hall = Room("DINING HALL π₯")
dining_hall.set_description("it makes you hungry...")
study = Room("STUDY π")
study.set_description("a dusty room with a messy desk")
#Create items and their attributes
cheese = Cheese("piece of CHEESE π§")
kitchen.set_item(cheese)
potions = Potions("POTIONS π§ͺ")
dining_hall.set_item(potions)
color_one = "π΅ BLUE"
color_two = "π΄ RED"
#Links the rooms
kitchen.link_room(dining_hall, "south") # This links the kitchen to the dining hall
dining_hall.link_room(kitchen, "north") # Go to the empty dictionary on room_classes
dining_hall.link_room(ballroom, "west")
ballroom.link_room(dining_hall, "east")
ballroom.link_room(study, "west")
############################ CREATE CHARACTERS ##########################################
#Creates Dave
dave = Enemy("π§ DAVE π§", "A smelly zombie...", "cheese")
dining_hall.set_character(dave) #Dave is in the dining hall
dave.set_conversation("My name is Dave, I'd like to eat your brains! π§ ")
dave.set_weakness("cheese")
#Creates Catrina
catrina = Friend("π CATRINA π", "A spooky skeleton")
ballroom.set_character(catrina) #Catrina is in the ballroom
catrina.set_conversation("Hi, I'm Catrina, do not be afraid. π")
catrina.set_gift("SHIELD π‘")
#Creates Franky
franky = Enemy("π§β FRANKY π§β", "A vampire, he hasn't seen the sun in a while...", "shield")
study.set_character(franky)
franky.set_conversation("Hi! Let me drink you blood! π©Έ")
franky.set_weakness("shield")
############################ functions to make code easier to read ##########################################
# Dave scenario
def zombie_scenario():
print("\n--> WATCH OUT! He bites! What will fight with?")
fight_with = input("\n> ").lower().strip()
win_or_lose = dave.fight(fight_with)
if win_or_lose == False:
print("\n")
print("β Game over.")
exit()
elif win_or_lose == True:
print("You're glad to have gotten rid of that CHEESE π§...")
print("\n")
# Potions scenario
def potions_scenario():
user_choice = (input("\n> "))
if user_choice == "red":
print("β You died. GAME OVER")
exit()
else:
print("You have chosen the π΅ BLUE potion.")
print("β It tastes bitter...Your appearance has changed. Enemies will now be nice to you for a while. π")
print(nothing)
# Franky scenario
def vamp_scenario():
print("\n--> WATCH OUT! He bites! You need to protect yourself! What will you use?")
fight_with = input("\n> ").lower().strip()
win_or_lose = franky.fight(fight_with)
if win_or_lose == False:
print("\n")
print("β Game over.")
exit()
elif win_or_lose == True:
print("Frankie is knocked out.\n")
franky.drop_item("KEY π")
print("\n")
print("--------------------------------------------")
print("| You took the KEY π and got away safely |")
print("--------------------------------------------")
print("\n THE END")
exit()
############################################################ GAME STARTS ###############################################################
current_room = kitchen
inhabitant = current_room.get_character() #places the character in the room
print("\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+**+*+*+*+*+* β£ __ β£ π» WELCOME FOOLISH MORTAL TO THE HAUNTED MANSION π» β£ __ β£ ++**+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+**+*+*+*+*+*+*+*")
while True:
print("\n")
inhabitant = current_room.get_character()
#### Cheese
if inhabitant is None:
current_room.get_details()
kitchen.set_item(cheese)
cheese.describe()
command = input("\n> ").lower().strip()
if command == "eat it":
print("You died. Game over. π")
exit()
elif command == "take it":
print('β You put the CHEESE π§ in your satchel.')
kitchen.remove_item()
print(nothing)
current_room.direction_help()
print(which_direction)
command = input("\n> ").lower().strip()
current_room = current_room.move(command)
else:
print("β Please choose between the two options.")
#### Dave
if inhabitant is dave:
current_room.get_details()
print("\n")
inhabitant.describe()
inhabitant.talk()
zombie_scenario()
current_room.remove_character()
#### Potions
dining_hall.set_item(potions) ## Find the potions in the Dining Hall
potions.describe(color_one, color_two)
potions_scenario()
current_room.direction_help()
print(which_direction) ## Choose which direction to go
command = input("\n> ").lower().strip()
current_room = current_room.move(command)
current_room.direction_help()
inhabitant = current_room.get_character()
#### Catrina
if inhabitant is catrina:
current_room.get_details()
print("\n")
inhabitant.describe()
inhabitant.talk()
print("\n")
print("β What would like to do? CHANGE ROOM or TALK?")
command = input("> ").lower().strip()
if command == "change room":
current_room.direction_help()
print(which_direction)
command = input("\n> ").lower().strip()
current_room = current_room.move(command)
current_room.get_details()
elif command == "talk":
inhabitant.give_item()
inhabitant = None
print("She left...")
print("\n")
print("β Your appearence changed back to normal.")
print(nothing)
current_room.direction_help()
else:
print("β Please choose between the two options.")
exit()
if inhabitant is None:
print(which_direction)
command = input("\n> ").lower().strip()
current_room = current_room.move(command)
#### Franky
if inhabitant is franky:
current_room.get_details()
print("\n")
inhabitant.describe()
inhabitant.talk()
vamp_scenario()