/
adventuregame.py
275 lines (196 loc) · 14.3 KB
/
adventuregame.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
#Adventure Game
#Andrew D. Sapolnick, David Lear, Suved Adkar (C)2010
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
print "Welcome to the Adventure Game, here you will embark on a dangerous journey to defeat the evil Dragon named Kibbles, and rescue Princess Catherine, You're story begins in the small town of Jersey, type the commands north, south, east, and west in order to navigate,type the command use followed by the item name to use an item, type the command inventory to look at the items in your posession, type the command look to look around you, type the command search followed by a target to search for people or items, type the command commands to repeat these directions. Good luck"
items=[]
place=1
town=2
forest=3
mine=4
lair=5
dead=6
game=0
on=90
win=91
game=on
place=town
lose=92
while game==on:
while place==town:
direction=raw_input("What would you like to do?\n")
if direction=="west":
if "iron ore" and "wood" and "3 Gold Pieces" in items:
print "the blacksmith greets you, and you tell him that you have the items and money he requires, you also give him the saw to make up for some of the difference, he then forges you a battleaxe and wishes you luck on the rest of your quest"
items.remove ("saw")
items.remove ("3 Gold Pieces")
items.remove ("iron ore")
items.remove ("wood")
items.append ("battleaxe")
else:
print "You are at the blacksmith shop, many different kinds of weapons decorate the walls, the blacksmith is a tall, hairy man who smiles as you enter the door. You tell him that you need a weapon to kill Kibbles the Evil Dragon. He laughs and says 'Mah boy! Killing Kibbles is what all true warriors strive for! But you can't do it with any of my weapons, you need Atari, the magic sword that lies in the cave east of the forest. Many have tried to get it, but all have failed as it is guarded by the evil wizard Gwonam! If you're looking to fight Gwonam, I can make you an axe, but you need to bring me iron ore, wood, and some gold for my troubles.' You then decide to head into the forest to seek out the materials for the blacksmith"
elif direction=="north":
print "You walk up the gates of the king's castle, the guards stop and ask you to state your business, you tell them that you want to rescue Princess Catherine. They laugh and tell you that you should probably obtain a weapon first, you head back to the center of town"
elif direction=="east":
print "You head into the residential district of town, a few huts line the streets, but there isn't much else of note here, you decide to head back to the center of town"
elif direction=="south":
print "You head deep into the forest"
place=forest
elif direction=="commands":
print "type the commands north, south, east, and west in order to navigate,type the command use followed by the item name to use an item, type the command inventory to look at the items in your posession, type the command look to look around you, type the command search followed by a target to search for people or items, type the command commands to repeat these directions"
elif direction=="inventory":
print items
elif direction=="look":
print "You're located in the small town of Jersey, here you see a blacksmith shop to the west, the king's castle to the north, houses to the east, and the town's exit to the forest to your south"
elif "use" in direction:
print "You have nothing to use"
elif "search" in direction:
print "There's nothing of importance to search"
else:
print "Please type a command"
while place==forest:
direction=raw_input("What would you like to do?\n")
if direction=="west":
print "You head into the mine"
place=mine
elif direction=="south":
print "The mountains look too treacherous to try and pass through. It might not hurt to try and look for that man though."
elif direction=="east":
if "battleaxe" in items:
print "You head into Gwonam's Lair"
place=lair
else:
print "it's not a good idea to go to Gwonam's lair unprotected"
elif direction=="north":
print "You head back to Jersey"
place=town
elif direction=="look":
print "You are at the center of a vast forest, surrounded by many tall trees, you could defintiely obtain some wood from some of them, but you would need the proper tools. To your west lies a mine, to your south a group of impassable mountains, but you can hear a person in the distance, to your east lies the evil gwonam's lair, and to the north lies Jersey"
elif "use" in direction:
if "pickaxe" in direction:
if "iron ore" in items:
if "man" or "person" in directions:
print "The man looks at the pickaxe with sorrow and tells you that this was his brothers pickaxe, he offers you his saw for it and you accept."
items.append ("saw")
items.remove ("pickaxe")
if "saw" in direction:
if "saw" in items:
if "tree" in direction:
print "you use the saw to cut some wood off of a nearby tree"
items.append ("wood")
else:
print "you can't use that"
elif direction=="inventory":
print items
elif "search" in direction:
if direction== "search person":
print "You find the man, he appears to be a lumberjack and is carrying a large saw. You tell him about your quest and the items you are looking for. He directs you to the mine for the iron ore and tells you that he's always wanted to be a miner like his brother. He tells you that his brother is in the mines right now if you should need any help."
else:
print "You can't search for that"
elif direction=="commands":
print "type the commands north, south, east, and west in order to navigate,type the command use followed by the item name to use an item, type the command inventory to look at the items in your posession, type the command look to look around you, type the command search followed by a target to search for people or items, type the command commands to repeat these directions"
while place==mine:
direction=raw_input("What would you like to do?\n")
if direction=="west":
print "The cavern is too dark to travel down, you head back to the center of the mine"
elif direction=="east":
print "You head back to the forest"
place=forest
elif direction=="south":
print "You are at a desposit of rich iron, this is perfect for the blacksmith, the only problem is you don't have a way to mine it"
elif direction=="north":
print "You are in a small cavern with a dead body on the floor, you are not sure how he died. You see a pickaxe underneath him and a bag around his waist"
elif direction=="look":
print "You find yourself in the center of a large mine. To your east lies the exit back to the forest, to your north lies a cavern with a dead body, to your south lies an iron deposit, and to your west lies a very dark cavern."
elif "search" in direction:
if "body" in direction:
if "pickaxe" not in items:
print "You take the pickaxe and the bag which contained 3 Gold Pieces"
items.append ("pickaxe")
items.append ("3 Gold Pieces")
else:
print "You cannot search that"
elif "use" in direction:
if "pickaxe" in direction:
if "pickaxe" in items:
if "iron" in direction:
print "You use the pickaxe to mine the iron ore"
items.append ("iron ore")
else:
print "You cannot use that"
elif direction=="inventory":
print items
elif direction=="commands":
print "type the commands north, south, east, and west in order to navigate,type the command use followed by the item name to use an item, type the command inventory to look at the items in your posession, type the command look to look around you, type the command search followed by a target to search for people or items, type the command commands to repeat these directions"
while place==lair:
direction=raw_input("What would you like to do?\n")
if direction=="west":
print "You head back into the forest"
place==forest
elif direction=="south":
if "Atari" not in items:
print "You see Gwoman's scary looking 'Faces of Evil' paintings hanging on the wall, you head down the corridor and come face to face with the evil wizard. He screams 'Zreep!' and tries to attack you with a magic spell!"
action=raw_input ("What will you do?")
if "axe" in action:
print "You manage to dodge the spell, you lunge forward and cut off Gwonam's head. He screams 'Squadalllllllllahhhhhhhhhhh' as he dies as if it's some sort of spell, but who cares, you did it! Atari the magic sword hangs on the wall, it's finally yours now, time to fight Kibbles!"
items.append ("Atari")
print "You head back to the center of the lair"
place=lair
else:
print "You get hit with the spell, you can hear Gwonam laughing as you feel immense pain and everything begins to fade to black. You realize that this is it, and you do not feel bad about losing your own life, only that you could not save Princess Catherine. Here is where your Adventure ends."
game==lose
place=dead
elif direction=="east":
if "key" in items:
print "You run down the long hallway and reach Princess Catherine's cell."
cell=1
locked=2
cell=locked
while cell==locked:
action=raw_input("What would you like to do?")
if "key" in action:
cell=1
print "You unlock the cell door and rescue the Princess! She hugs you and thanks you for saving her. You escort her back to Jersey and become a legendary hero!"
game=win
place=dead
else:
print "You head down a long hallway and reach a jail cell holding Princess Catherine, she screams to you for help, but the door is locked. She tells you the key is in the room and guarded by Kibbles the Evil Dragon. You promise her that you will save her and head back to the center of the lair"
elif direction=="north":
if "Atari" in items:
print "You run down the hallway and reach a giant room. You finally come face to face with the Evil Kibbles the Dragon. He towers over you and begins to roar when you enter the room. He charges at you and breathes fire in your direction"
action=raw_input("What will you do?")
if "Atari" or "Sword" in action:
print "You unsheate Atari, it begins to glow and surrounds you with a protective shield. The fire bounces off the shield and you swing it at Kibbles' neck, decapitating him. You did it! You pick up the key on the table that Kibbles' was guarding, now all that's left is to save the Princess!"
items.append ("key")
else:
print "You get hit by the fire, it scorches your body and you feel excrutiating pain all over. A deep sense of regret fills you as you realize that you were unable to save Princess Catheine. Kibbles picks you up and beings to devour you whole. Your adventure ends here."
game=lose
place=dead
else:
print "You do not have Atari yet, it would be suicide to try and fight Kibbles"
elif direction=="look":
print "You are at the center of the evil Gwonam's lair. To the north lies Kibbles the evil dragon, to the south lies Gwonam's room, to the east lies the jail, and to the west is the exit back to the forest."
elif "use" in direction:
print "I would worry about using that now, let's just try and rescue the Princess"
elif direction=="commands":
print "type the commands north, south, east, and west in order to navigate,type the command use followed by the item name to use an item, type the command inventory to look at the items in your posession, type the command look to look around you, type the command search followed by a target to search for people or items, type the command commands to repeat these directions"
elif direction=="inventory":
print items
elif "search" in direction:
print "Let's not search that now, we have to save the Princess!"
while game==lose:
print "Thank you for playing, Try again and see if you can rescue Princess Catherine!"
game=99
raw_input ("Press enter to exit the program")
while game==win:
print "Congratulations! You beat the Adventure game! Thank you for playing!"
game=99
raw_input ("Press enter to exit the program")