- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNavigation.py
More file actions
Latest commit
390 lines (390 loc) · 22.8 KB
/
Copy pathNavigation.py
File metadata and controls
390 lines (390 loc) · 22.8 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
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
fromEnemyimportEnemy, Boss
fromEnemy_valuesimportrat_king, rat_minions, Magical_IRS_Agent_TM
fromrandomimportrandint, choice
fromWeaponsimportWeapon, Staff, table_leg, golden_chains, giant_ladle, gungir, mop
fromPlayerimportPlayer
fromSpells_and_Special_movesimportfireball
importpickle
fromItemsimportItems, Health, Mana, protein_shake, mug_of_soup, cheese
importpygame
fist=Weapon(2,"Fist","Common", "fist")
pygame.mixer.init()
door1=pygame.mixer.Sound("Music/Delvin_sound_effects/Door/Creeking door.mp3")
door2=pygame.mixer.Sound("Music/Delvin_sound_effects/Door/Metal door.mp3")
doors= [door1, door2]
background_music=pygame.mixer.music.load('Music/Music/kaden_cook-8-bit-dungeon-251388.mp3')
defoption_validation(option:str):
ifoption=="1"oroption=="2":
returnoption
else:
print("Please enter a number")
option=input("Choose [1]fight or [2]run\n>")
defoption_system():
choice=input("Choose [1]fight, [2]inventory, [3]run\n>")
returnchoice
health_potion=Health("small health potion", 20)
mana_potion=Mana("small mana potion", 20)
kings_staff=Staff(10, "staff", "Legendary", "King's mic")
defcombat_encounter(opponent:Boss, Delvin:Player):
opponent.reset()
whileTrue:
print(f"\n{opponent.name} HP: {opponent.HP}, MP: {opponent.mana}")
print(f"Delvin HP: {Delvin.HP}, MP: {Delvin.mana}")
choice=option_validation(option_system())
ifchoice=="1":
Delvin.attack(opponent)
elifchoice=="2":
Delvin.open_inventory()
elifchoice=="3":
break
ifopponent.HP<=0:
duplicat=False
Delvin.HP+=30
ifopponent.dropped_item!="":
print(f"\n{opponent.name} has dropped a {opponent.dropped_item.name}")
print("Will Delvin pick it up?")
item=input("[Y]yes or [N]no? ")
ifitem.lower() =="y":
Delvin.equip_weapon(opponent.dropped_item)
else:
print(f"Delvin does not pick up the {opponent.dropped_item.name}")
forspellinDelvin.learned_spells:
ifspell.name==opponent.spells[-1].name:
duplicat=True
ifduplicat!=True:
Delvin.learn_spell(opponent.spells[-1])
ifisinstance(delvin.add_level(opponent), bool):
delvin.add_stat()
returnFalse
ifDelvin.HP<=0:
returnTrue
else:
opponent.attack_player(Delvin)
defnew_game()->str:
print('''Test text:What Class is Delvin?
[1] Mage
[2] Warrior
[3] Thief
[4] Spearman
[5] Peasant''')
whileTrue:
try:
choice=int(input("> "))
ifchoice==1:
choice="Mage"
returnchoice
elifchoice==2:
choice="Warrior"
returnchoice
elifchoice==3:
choice="Thief"
returnchoice
elifchoice==4:
choice="Spearman"
returnchoice
elifchoice==5:
choice="Peasant"
returnchoice
else:
print("Please choose a number between 1 and 5")
exceptValueError:
print("Please enter a number.")
defintro()->None:
globaldelvin
print("What would you like to do?")
print("[1] load previos save")
print("[2] begin a new adventrue")
choice=input("> ")
ifchoice=="1":
load()
elifchoice=="2":
delvin=Player(100,5, 5, 5, 5,100,"Delvin","A cowaradly man who is running from the Magical I.R.S Agents TM",new_game())
elifchoice=="3":
delvin=Player(100,100,100,100,100,100,"Big Delvin","God Mode delvin","Warrior")
deffloor1_scripted_events(room:str):
globalfloor
globalcurrent_location
ifroom=="Rat_room":
rat_minions[0].equip_weapon(mop)
rat_minions[0].dropped_item=mop
pygame.mixer.music.stop()
pygame.mixer.music.load("Music/Music/psychronic-the-never-ending-fight-227256.mp3")
pygame.mixer.music.play(-1)
returncombat_encounter(rat_minions[0], delvin)
elifroom=="Choice room":
print("\nWhich bottle will Delvin take?")
choice=input("[1] health potion, [2] mana potion")
choice=choice_validation(choice, 2)
ifchoice==1:
delvin.add_inventory(health_potion)
elifchoice==2:
delvin.add_inventory(mana_potion)
elifroom=="Mess hall":
rat_minions[1].dropped_item=table_leg
pygame.mixer.music.stop()
pygame.mixer.music.load("Music/Music/psychronic-fight-or-fall-493954.mp3")
pygame.mixer.music.play(-1)
rat_minions[1].equip_weapon(fist)
delvin.add_inventory(protein_shake)
returncombat_encounter(rat_minions[1], delvin)
elifroom=="Kitchen":
rat_minions[2].dropped_item=giant_ladle
pygame.mixer.music.stop()
pygame.mixer.music.load("Music/Music/studiokolomna-risk-136788.mp3")
pygame.mixer.music.play(-1)
delvin.add_inventory(mug_of_soup)
returncombat_encounter(rat_minions[2], delvin)
elifroom=="Royal Lounge":
rat_minions[3].dropped_item=golden_chains
pygame.mixer.music.stop()
pygame.mixer.music.load("Music/Boss_music/dstechnician-club-fight-113462.mp3")
pygame.mixer.music.play(-1)
delvin.add_inventory(cheese)
returncombat_encounter(rat_minions[3], delvin)
elifroom=="Royal chamber Gates":
rat_minions[4].dropped_item=gungir
pygame.mixer.music.stop()
pygame.mixer.music.load("Music/Music/17406877-battle-of-the-dragons-8037.mp3")
pygame.mixer.music.play(-1)
returncombat_encounter(rat_minions[4], delvin)
elifroom=="Throne Room":
pygame.mixer.music.stop()
pygame.mixer.music.load("Music/Music/Boombastic.mp3")
pygame.mixer.music.play(-1)
rat_king.equip_weapon(kings_staff)
returncombat_encounter(rat_king, delvin)
elifroom=="floor 2":
floor=2
current_location="Entrance 2"
answers= [1, 2, 3, 4]
# 1=Left 2=Right 3=Forward 4=Back
defcaught_end():
print("Delvin decides that he would rather not risk his life inside the dungeon and should instead try to find somewhere else to hide instead.\nAscending the stairs, Delving begins to think of what he should do when all of this blows over and the Magical I.R.S TM stops hunting him down.\nDelvin finally reaches the surface and is immediately blinded by a bright light 'FREEZE SCUM'.\nDelvin immediately complies and, as his eyes adjust, his worst nightmare comes true.\nStanding there in an immaculate suit stands a Magical I.R.S Agent TM.\nDelvin prepares himself for a last desperate struggle.")
pygame.mixer.music.stop()
pygame.mixer.music.load("Music/Music/Boss_music/psychronic-wacky-fight-317983.mp3")
pygame.mixer.music.play(-1)
combat_encounter(Magical_IRS_Agent_TM, delvin)
floor1_map= {
#Floor 1
"Surface": {
"description": "\nDelvin delves into the dungeon, each step making the sun's light dim a little bit more as he descends the stairs.\nAfter three near falls, a very angry bat, and a falling pebble that DEFINITELY DID NOT MAKE DELVIN SCREAM LIKE A LITTLE GIRL, Delvin finally arrives in the first room of the dungeon.",
"forward": "Entrance",
"back": "caught ending"
},
"Entrance": {
"description": "\nThe first thing Delvin sees is that the place is surprisingly clean for a dungeon.\nThe floors looked like they were regularly cleaned and there was a red carpet that seemed to lead to every entrance and exit in the room.\nThe walls are adorned with paintings of various types of cheeses and golden statues of a large rat with a crown are in every corner of the room.\nAfter having a small existential crisis about how dungeon monsters have better living conditions than him, Delvin begins his descent to find a safe haven from those pesky Magical I.R.S Agents TM.",
"visited_description": "Delvin slowly makes his way back to the entrance, making sure to be as quiet and stealthy as possible lest he alert any Magical I.R.S Agents TM that may be nearby.",
"left": "Treasure_room",
"right": "Rat_room",
"forward": "Rock_room",
"back": "Surface"
},
"Rat_room": {
"description": "\n'IS THAT A RAT!' is the first thing that comes to mind when Delvin enters the room.\nA bipedal rat creature is attempting to stealthily eat a piece of cheese while hiding in what seems to be a janitor's closet.\nThe young rat? Ratling? Didn't seem to like that Delvin interrupted their snack break.\nOh well, at least now Delvin knows why the dungeon is suspiciously clean.",
"visited_description": "\nThe corpse of the young Rat still sits there motionless on the ground looking at Delvin with those cold dead eyes.",
"back": "Entrance",
"trigger": False
},
"Treasure_room": {
"description": "Gold. Gold as far as the eye can see. Delvin walks in and gazes up at mountains upon mountains of gold shining, shimmering, and practically begging to be taken.\nDelvin immediately begins to fill his bag with as much gold as he can physically fit into it.\nWith this money he will have more than enough to pay off the Magical I.R.S Agents TM and then some. He becomes so happy that he bites into one of the coins to make sure he isn't dreaming. The good news is he isn't dreaming.\nThe bad news is his teeth easily go through the coin and it tastes like chocolate. Delvin stares with hollow eyes at the coins in his bag for an uncomfortably long time.",
"visited_description": "Despite the damp environment, the coins remain unmelted. Delvin feels like they are mocking him.",
"back": "Entrance",
},
"Rock_room": {
"description": "Delvin goes through another damp corridor, expecting the usual scary monster to pop out and attack him.\nInstead, he pushes open a heavy stone door and finds...rocks.\nJust rocks.\nTiny rocks, big rocks, suspiciously rock-shaped rocks, and one boulder that somehow looks smug.\nDelvin carefully nudges a pebble with his boot.\nIt remains deeply committed to being a pebble.",
"visited_description": "Despite all the odds and all of Delvin's adventures, the room sits perfectly still, not that rocks could move in the first place but, they still stand there motionless and unmoving. The longer Delvin stares, the more intimidated he becomes by the rocks' unmoving nature and the boulders' smug aura.",
"left": "Mess hall",
"right": "Corridor",
"forward": "Royal Lounge",
"back": "Entrance",
},
"Mess hall": {
"description": """Delvin goes into the mess hall, where it was literally a mess.\nHe sees a bunch of malnourished rats cowering in the corner of the room.\nDelvin gazes upon the source of their fear, where the buffest rat he has ever seen was sitting upon a battered stool slinging protein drinks and lifting a big ball of rats.\nHis tiny gray head sat atop his ridiculously buff body, his shoulders alone were twice the size of his head.\nThe rat flexes his ridiculously large biceps and says, "Prepare yourself for... THE ULTIMATE BULK-OFF!" """,
"visited_description": """The ridiculously buff rat lies there on the floor deafeated\nHe mutters something about needing more protein shakes and weights.""",
"forward": "Kitchen",
"back": "Rock_room",
"trigger": False
},
"Kitchen": {
"description": "Delvin stumbles into the kitchen while various bits of food and wood scraps, dirty his clothes from his fight with the muscular rat fighter.\nIf someone mentions anything about protein or proper workout forms, Delvin is going to lose it. While Delvin stews in his misery, an absolutely divine smell hits his nose.\nImmediately Delvin zeros in on the source and begins to make his way to the back of the mess hall, passing by various overturned tables, discarded food trays, and cowering rats.\nFinally, he arrives in the kitchen.\nThe smells only grow stronger, making Delvin's stomach rumble with hunger.\nInside, a rat with a big hat stirs a pot of stew desperately as if his life depended on it before seeing Delvin and attacking.",
"visited_description": "Delvin revisits the kitchen pots, pans, and various other cooking utensils scattered about on the floor while appliances are broken beyond recognition.\nThe stew has long gone cold and no longer emits its heavenly aroma.\n Delvin stares at the busted stove.\n'The fire is gone...and I remember it best'.",
"back": "Mess hall",
"trigger": False
},
"Corridor": {
"description": "Delvin expected a lot of stuff, like a hallway with dozens upon dozens of pictures of that crowned rat, golden statues lining the walls, or a pack of rats that would ambush him.\nWhat he didn't expect was a regular corridor with stone walls.\nDelvin feels dissappointed.",
"visited_description": "It's still just a regular corridor.\nDelvin feels even more disappointed.",
"forward": "Choice room",
"back": "Rock_room",
},
"Choice room":{
"description": "Delvin stumbled upon a room with two podiums that stood at about waist height.\nA potion stood upon each podium, one with a red bottle and one with a blue bottle.",
"visited_description": "Delvin attempted to go back to the room with the two podiums, but the entrance had caved in.",
"back": "Corridor",
},
"Royal Lounge": {
"description": """Delvin arrives inside a room with, well... a rat.\nThe room appears to be the backstage of a concert.\nThe rat was skinny with big gold chains on his neck and one of them said, "Small Cheda".\nSmall Cheda seemed to be practicing for a diss battle.\nThat is until Delvin appears...\n """,
"visited_description": "Delvin walks backstage and all he sees is a rat-shaped scorch mark and Small Cheda's golden chains.",
"forward": "Long hallway",
"back": "Rock_room",
"trigger": False
},
"Long hallway": {
"description": "Delvin is really starting to regret going to this dungeon after defeating 'Small Cheda' and his entourage.\nNot only is this dungeon full of impossibly smug boulders, but, it also has rats.\nCouldn't he have picked a better dungeon to hide from the Magical I.R.S Agenst TM.\nHe's been walking down this hallway for what felt like hours now, and he is pretty sure he has been looping the room.",
"visited_description": "The hallway is actually starting to grow on Delvin.\nIt's so peaceful and quiet.\nAs he reaches the end of the room, he grows sad, longing for the peacefullness that this back room provided.",
"forward": "Royal chamber Gates",
"back": "Royal Lounge",
},
"Royal chamber Gates": {
"description": "Finally, at long last, Delvin sees salvation. In the far distance, he spots what looks like a set of golden armor standing in front of a massive chamber door.\nDelvin doesn't care whether that armor is haunted or the room behind it is full of Rats. He's just happy to finally be able to see something other than the monotonous stone walls of the hallway.\nFortunately for Delvin, the armor is not haunted. Unfortunately, it seems instead to be a guard who is not too happy to see a human.",
"visited_description": "Delvin makes his way back to the poor guard who was stationed at the door.\nHe looks upon the cracked armor and broken visage of a once brave and noble knight who was blinded by his own loyalty.\nDelvin develops a strange feeling as if this is the final resting place of a legendary figure.",
"forward": "Throne Room",
"back": "Long hallway",
"trigger": False
},
"Throne Room": {
"description": "As soon as Delvin enters the chamber, he is immediately blasted by loud music and bright lights.\nA roar of applause sounds out as Delvin steps through the door.\nWhen his eyes clear, he is met with a sight unlike any other.\nAll around the walls of the circular chamber sit rows upon rows of rats, all of them cheering and looking at a figure in the direct center of the chamber.\nThereupon a raised platform is the biggest rat Delvin has ever seen and atop his head sits a golden crown on top of a backwards baseball cap.\nThe rat turns to Delvin and speaks 'Ah, small Cheda finally done with your pathetic little warm ups' the rat does not wait for an answer 'Perfect then lets get started and watch as I wash you away with my flow'",
"visited_description": "How can a once-lively place feel so barren and empty.\nLooking throughout the room, Delvin sees that there really isn't much left of the luxurious throne room he was in before; now all that remains is a king's broken crown and the faint echo of electronic music.",
"forward": "floor 2",
"back": "Long hallway",
"trigger": False
}
#Floor 2
}
current_location="Surface"
floor1_boss=False
floor2_boss=False
floor3_boss=False
floor=1
floor_data= [current_location, floor1_boss, floor2_boss, floor3_boss, floor]
defexploration():
pygame.mixer.music.stop()
background_music
pygame.mixer.music.play(-1)
directions= ["left", "right", "forward", "back"]
globalcurrent_location
globaldelvin
whiledelvin.HP>0:
trigger=True
options= []
viseted=False
current_room=current_location
forkey, valueinfloor1_map[current_room].items():
ifkey=="trigger"andvalue==True:
trigger=False
ifkeyindirections:
options.append(key)
ifkey=="visited"andisinstance(value, bool) andvalue==True:
viseted=True
ifviseted==True:
ifcurrent_room!="Surface":
print(floor1_map[current_room]["visited_description"])
else:
print(floor1_map[current_room]["description"])
iffloor==1:
iftrigger:
iffloor1_scripted_events(current_location):
print("Delvin is knocked unconcious giving the Magical I.R.S Agents TM plenty of time to find and capture him.")
print("\nGAME OVER\n")
return
floor1_map[current_room]["trigger"] =True
path=navigation(options)
sound=choice(doors)
sound.play()
ifpath==1:
path=options[0]
elifpath==2:
path=options[1]
elifpath==3:
path=options[2]
elifpath==4:
path=options[3]
elifpath==0:
floor_data[0] =current_room
save(delvin, floor1_map, floor_data)
print("\nYou have saved the game\n")
elifpath==5:
break
elifpath==6:
delvin.open_inventory()
ifpath!=0andpath!=5andpath!=6:
floor1_map[current_room]["visited"] =True
current_location=floor1_map[current_room][path]
ifcurrent_location=="caught ending":
print("\nCONGRATULATIONS you got the 'Caught' Ending\n")
caught_end()
break
defsave(player:Player, world:dict, floor_data:list):
withopen("Player_data.pkl", "wb") asfile1:
pickle.dump(player, file1)
withopen("Dungeon_data.pkl", "wb") asfile2:
pickle.dump(world, file2)
withopen("Floor_data.pkl", "wb") asfile3:
floor_data.append(current_location)
pickle.dump(floor_data, file3)
defload()->str:
globaldelvin
globalfloor1_map
globalfloor3_boss
globalfloor2_boss
globalfloor1_boss
globalfloor
globalcurrent_location
try:
withopen("Player_data.pkl", "rb") asfile1:
delvin=pickle.load(file1)
withopen("Dungeon_data.pkl", "rb") asfile2:
floor1_map=pickle.load(file2)
withopen("Floor_data.pkl", "rb") asfile3:
floor_data=pickle.load(file3)
floor3_boss=floor_data[3]
floor2_boss=floor_data[2]
floor1_boss=floor_data[1]
floor=floor_data[4]
current_location=floor_data[0]
returncurrent_location
except:
print("You have no previous save file")
deff1_r10():
pass
deff1_r13():
pass
# def f1_r9():
# options = ["Door to the North beside the entrance", "Door to the North farthest from the entrance", "Door to the East", "Locked door to the South", "Locked door to the West"]
# print("Delvin delves into the dungeon, each step making the sun's light dim a little bit more as he descends down the stairs.\nAfter three near falls, a very angry bat, and a falling pebble that DEFINIETLY DID NOT MAKE DELVIN SCREAM LIKE A LITTLE GIRL, Delvin finally arrives at the first room of the dungeon.")
# if random_encounter():
# print("Finally putting down his dastardly assailant Delvin cries a little and begins to question his life choices.\nNevertheless, Devlin eventually manages to put on a brave face and pull himself together ")
# print('''After a quick bout of positive affirmations whispered under his breath Delvin looks around the room spotting seven doors.
# The first three doors are to his North with the first being the way he came which is now locked, the second is directly beside the entrance door in the top left corner of the room it seems unlocked and leads to a corridor, the third sits in the upper left hand corner of the room and seems to lead to a massive theatre like room.
# Gazing towards the south''')
#START FROM HERE
# def random_encounter():
# if randint(1, 10) <= 3:
# print("\nLLLLLLLEEEEEEEEEEEEERRRRRRRRRRRRROOOOOOOOOOOOOOYYYYYYYYYYYYYYYYYYYY JJJEEEEEEEENNNNNNKKKKKIIIIINNNSSSSSS!!!!!!!!!!!!!!!")
# print("Before Delvin can even get his barrings he is attacked by an assaliant hidden in the shadows.")
# print("Delvin draws his weapon and prepares for battle.")
# assailant = choice(rat_minions)
# combat_encounter(assailant, delvin)
# return True
defchoice_validation(choice:str, num_of_options:int):
whileTrue:
ifchoice.isdigit():
ifint(choice) <=num_of_optionsorint(choice) ==5orint(choice) ==0orint(choice) ==6:
returnint(choice)
print("Delvin decides to forge his own path through the dungeon and fails miserably.")
choice=input("> ")
defnavigation(options:list):
print("Which way will Delvin go?")
forindex, optioninenumerate(options, start=1):
print(f"[{index}] {option}")
print(f"[0] save")
print(f"[5] quit")
print(f"[6] inventory")
choice=input("> ")
choice=choice_validation(choice, index)
returnchoice
if__name__=="__main__":
intro()
exploration()
# rat_king.equip_weapon(kings_staff)
# combat_encounter(rat_king, delvin)