-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTheSpookyHouse_Game.py
More file actions
230 lines (134 loc) · 5.35 KB
/
TheSpookyHouse_Game.py
File metadata and controls
230 lines (134 loc) · 5.35 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
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 11 18:30:09 2021
@author: Dikhsha
"""
from room import Room
from character import Enemy,Friend
from item import Item
from gameinfo import GameInfo
game_name = GameInfo('The Spooky House')
game_name.welcome()
GameInfo.info()
#print(kitchen.name)
#Setting up rooms for the game
kitchen = Room('Kitchen')
ballroom = Room('ballroom')
dining_room = Room('dining_room')
ballroom.set_description("A vast room with a shiny wooden floor; huge candlesticks guard the entrance")
dining_room.set_description("A large room with ornate golden decorations on each wall")
kitchen.set_description("A dank and dirty room buzzing with flies")
#print(ballroom.get_description())
#print(dining_room.get_name())
kitchen.set_name('kitchen')
#print(kitchen.get_name())
kitchen.link_room(dining_room,'south')
dining_room.link_room(ballroom, 'west')
ballroom.link_room(dining_room,'east')
dining_room.link_room(kitchen,'north')
ballroom.link_room(kitchen,'northeast')
kitchen.link_room(ballroom,'southwest')
#print(ballroom.linked_rooms)
#dining_room.get_details()
#moving players form on room to another
'''current_room = dining_room
while True:
print('\n')
current_room.get_details()
command = input(' > ')
current_room = current_room.move(command)'''
#setting up enemy
#enemy1
dave = Enemy('Dave', 'A smelly zombie!!')
dave.set_conversation('urrghhhh....murrhrhh..guuhhh..')
dave.set_weakness('hot iron')
#enemy2
karen = Enemy('Karen','A racist white women')
karen.set_conversation('Go back to where you came from ')
karen.set_weakness('coke')
#friend1
micheal = Friend('Mike','A friendly fluffy dog')
micheal.set_conversation("Hi, I am so happy to see you!")
#dave.describe()
#setting up enemy in a room
dining_room.set_character(dave)
ballroom.set_character(karen)
kitchen.set_character(micheal)
print('No of rooms : ', Room.no_of_rooms)
current_room = dining_room
#setting up an item in a room
energy_drink = Item('Energy Drink')
energy_drink.set_description('It helps you energize for your next adventure!!')
hot_iron = Item('hot iron')
hot_iron.set_description('Can of hotiron to be used as a weapon')
coke = Item('coke')
coke.set_description('Drink to cool down a certain enemy')
#setting items in rooms
dining_room.set_item(energy_drink)
ballroom.set_item(hot_iron)
kitchen.set_item(coke)
#setting a backpack for player to collect items
backpack = []
def take(item):
if item != None:
backpack.append(item.name)
while current_room is not None:
inhabitant = current_room.get_character()
print("You are in :")
current_room.get_details()
print('\n')
room_item = current_room.get_item()
if room_item == None:
print('No item in the room to collect')
print('\n')
else:
room_item.get_description()
take(room_item)
current_room.set_item(None)
print(room_item.name + ' added to your backpack')
#print(backpack)
if inhabitant == None:
print('No enemy/friend in the room')
print('\n')
command = input(' Which direction to go next: ')
current_room = current_room.move(command.lower())
else:
inhabitant.describe()
print('\n')
command = input('What do you want to do: ')
if command.lower() in ['north','south','east','west','northeast','southwest']:
current_room = current_room.move(command.lower())
print('\n')
elif command.lower() == 'talk':
#print('\n')
inhabitant.talk()
print('\n')
elif command.lower() == 'fight':
if isinstance(inhabitant,Enemy) == True:
weapon = input('Choose your weapon: ')
if weapon in backpack and inhabitant.fight(weapon) == True:
if Enemy.enemies_defeated == 2:
print('CONGRATULATIONS YOU WON THE GAME!!')
break
else:
continue
else:
print('You do not have the weapon to fight '+ inhabitant.name +' GAME ENDED')
break
else:
print('You cannot fight ', inhabitant.name)
continue
elif command.lower() == 'hug':
if isinstance(inhabitant,Friend) == True:
inhabitant.hug()
continue
else:
print('You cant hug ', inhabitant.name)
else:
break
GameInfo.credits()
#diksha = Item('diksha')
#diksha.set_description('cute sweet girl')
#diksha.set_item_location('kitchen')
#print(diksha.get_description())
#print(diksha.get_item_location())