def BackOfHouse(back_inp): alive = True room_num = 5 if 'pick up' in back_inp.lower(): item = (back_inp.lower())[8:] items.pick_up(item, room_num) elif 'put down' in back_inp.lower(): item = (back_inp.lower())[9:] items.put_down(item, room_num) elif 'use' in back_inp.lower(): item = (back_inp.lower())[4:] items.useItem(item) elif back_inp.lower() == 'show inventory' or back_inp.lower() == 'inventory': print("---------------------------------------------------------") print(*items.inventory, sep = ', ') elif back_inp.lower() == ("go south") or back_inp.lower() == ("follow path"): room_num = 4 elif back_inp.lower() == ("go west") or back_inp.lower() == ("enter house"): room_num = 6 print("---------------------------------------------------------") print("Opening a rickety window you climb into the house.") elif back_inp.lower() == ("kick the bucket"): alive = False else: print("---------------------------------------------------------") return [room_num, alive]
def AtticRoom(attic_inp): alive = True room_num = 7 if 'pick up' in attic_inp.lower(): item = (attic_inp.lower())[8:] items.pick_up(item, room_num) elif 'put down' in attic_inp.lower(): item = (attic_inp.lower())[9:] items.put_down(item, room_num) elif 'use' in attic_inp.lower(): item = (attic_inp.lower())[4:] items.useItem(item) elif attic_inp.lower() == 'show inventory' or attic_inp.lower() == 'inventory': print("---------------------------------------------------------") print(*items.inventory, sep = ', ') elif attic_inp.lower() == 'show inventory' or attic_inp.lower() == 'inventory': print("---------------------------------------------------------") print(*items.inventory, sep = ', ') elif attic_inp.lower() == ("go down stairs") or attic_inp.lower() == ("go down"): room_num = 6 elif attic_inp.lower() == ("kick the bucket"): alive = False else: print("---------------------------------------------------------") return [room_num, alive]
def KitchenRoom(kitchen_inp): alive = True room_num = 6 if 'pick up' in kitchen_inp.lower(): item = (kitchen_inp.lower())[8:] items.pick_up(item, room_num) elif 'put down' in kitchen_inp.lower(): item = (kitchen_inp.lower())[9:] items.put_down(item, room_num) elif 'use' in kitchen_inp.lower(): item = (kitchen_inp.lower())[4:] items.useItem(item) elif kitchen_inp.lower() == 'show inventory' or kitchen_inp.lower() == 'inventory': print("---------------------------------------------------------") print(*items.inventory, sep = ', ') elif kitchen_inp.lower() == ("go up stairs") or kitchen_inp.lower() == ("go up"): room_num = 7 elif kitchen_inp.lower() == ("go east") or kitchen_inp.lower() == ("exit house"): room_num = 5 elif kitchen_inp.lower() == ("kick the bucket"): alive = False else: print("---------------------------------------------------------") return [room_num, alive]
def EastLoop(grating_inp, itemList): if grating_inp.lower() == ("go south"): if items.useItem('longsword', itemList): print("---------------------------------------------------------") print("You killed the ogre") print("You are entering the cave he was guarding") return [True, 5] else: print("You see a large ogre and turn around.") return [True, 3] elif grating_inp.lower() == ("descend grating"): return [True, 4] elif grating_inp[0:4].lower() == ("take"): return [True, 3, items.pick_up(grating_inp[5:], 3)] elif grating_inp.lower() == ("kick the bucket"): print("---------------------------------------------------------") print("You die.") print("---------------------------------------------------------") return [False, 0] elif grating_inp[0:8].lower() == ("put down"): if grating_inp[9:].lower() in itemList: items.put_down(grating_inp[9:], 3) return [True, 3] else: return [True, 3] else: print("---------------------------------------------------------") return [True, 3]
def room12(user_input): room = 12 print("---------------------------------------------------------") if user_input == ("go east"): print("---------------------------------------------------------") print ("You return to the forest.") room = 8 elif user_input == ("go west"): print("The mountains are impassiblble this time of year.") elif user_input == ("go north"): print("A roaring river blocks your way.") elif user_input == ("go south"): if items.useItem('sword', inventory): print('You used your sword to kill the uruks! You found a small gold ring, but more uruks are coming!\n\n You run back to the forest') items.pick_up('gold ring',12) room = 8 else: print("You wander into the evil lands and are killed by uruks") ded() elif user_input == ("kick the bucket"): print("You die.") print("---------------------------------------------------------") ded() else: print("---------------------------------------------------------") return room
def GratingRoom(grating_inp): alive = True room_num = 9 global lit if 'pick up' in grating_inp.lower(): item = (grating_inp.lower())[8:] items.pick_up(item, room_num) elif 'put down' in grating_inp.lower(): item = (grating_inp.lower())[9:] items.put_down(item, room_num) elif 'use' in grating_inp.lower(): item = (grating_inp.lower())[4:] if items.useItem(item): if item == 'lantern': lit = True elif grating_inp.lower() == 'show inventory' or grating_inp.lower() == 'inventory': print("---------------------------------------------------------") print(*items.inventory, sep = ', ') elif grating_inp.lower() == ("go south"): room_num = 12 elif grating_inp.lower() == ("go east"): room_num = 8 elif grating_inp.lower() == ("descend grating") or grating_inp.lower() == ("go down") or grating_inp.lower() == ("go down grating"): room_num = 10 elif grating_inp.lower() == ("kick the bucket"): alive = False else: print("---------------------------------------------------------") return [room_num, alive]
def LakeRoom(north_house_inp): global fish global fishin global caught alive = True room_num = 1 if 'pick up' in north_house_inp.lower(): item = (north_house_inp.lower())[8:] if item == 'fish': if caught: items.pick_up(item, room_num) else: print("---------------------------------------------------------") print("You have not caught any fish.") else: items.pick_up(item, room_num) elif 'put down' in north_house_inp.lower(): item = (north_house_inp.lower())[9:] items.put_down(item, room_num) elif 'use' in north_house_inp.lower(): item = (north_house_inp.lower())[4:] if items.useItem(item): if item == 'fishing rod': fishin = 1 elif north_house_inp.lower() == 'show inventory' or north_house_inp.lower() == 'inventory': print("---------------------------------------------------------") print(*items.inventory, sep = ', ') elif north_house_inp.lower() == ("go south"): room_num = 4 elif north_house_inp.lower() == ("swim"): print("---------------------------------------------------------") print("You don't have a change of clothes and you aren't here on vacation.") elif north_house_inp.lower() == ("fish") or north_house_inp.lower() == ("go fishing"): if fishin == 1: if fish != 3: print("---------------------------------------------------------") print("You spend some time fishing but nothing seems to bite.") fish += 1 elif fish == 3: print("---------------------------------------------------------") print("You finally caught a fish!") fish += 1 caught = True else: print("---------------------------------------------------------") print("You need to use the fishing rod in order to fish.") elif north_house_inp.lower() == ("kick the bucket"): alive = False else: print("---------------------------------------------------------") return [room_num, alive]
def TrunkRoom(last_inp): alive = True room_num = 11 global key global locked global lit global statue if 'pick up' in last_inp.lower(): item = (last_inp.lower())[8:] items.pick_up(item, room_num) elif 'put down' in last_inp.lower(): item = (last_inp.lower())[9:] items.put_down(item, room_num) elif 'use' in last_inp.lower(): item = (last_inp.lower())[4:] if items.useItem(item): if item == 'key': key = True if item == 'lantern': lit = True elif last_inp.lower() == 'show inventory' or last_inp.lower() == 'inventory': print("---------------------------------------------------------") print(*items.inventory, sep = ', ') elif last_inp.lower() == ("go up stairs") or last_inp.lower() == ("go up"): room_num = 10 elif last_inp.lower() == ("unlock trunk"): if key: print("---------------------------------------------------------") print("Trunk is now unlocked.") locked = False else: print("---------------------------------------------------------") print("You need to use something to unlock the trunk") elif last_inp.lower() == ("open trunk"): if not locked: print("---------------------------------------------------------") print("You have found the Jade Statue and have completed your quest!") statue = True else: print("---------------------------------------------------------") print("The trunk is still locked.") elif last_inp.lower() == ("kick the bucket"): alive = False else: print("---------------------------------------------------------") if alive and statue: room_num = 'end' return[room_num, alive]
def Field(second, itemList): if second.lower() == ("take mailbox"): print("---------------------------------------------------------") print("It is securely anchored.") return [True, 0] elif second.lower() == ("open mailbox"): print("---------------------------------------------------------") print("Opening the small mailbox reveals a leaflet.") return [True, 0] elif second[0:4].lower() == ("take"): return [True, 0, items.pick_up(second[5:], 0)] elif second.lower() == ("go north"): return [True, 1] elif second.lower() == ("open door"): print("---------------------------------------------------------") print("The door cannot be opened.") return [True, 0] elif second.lower() == ("take boards"): print("---------------------------------------------------------") print("The boards are securely fastened.") return [True, 0] elif second.lower() == ("look at house"): print("---------------------------------------------------------") print( "The house is a beautiful colonial house which is painted white. It is clear that the owners must have been extremely wealthy." ) return [True, 0] elif second.lower() == ("go east"): print("---------------------------------------------------------") print("You walk around to the back of the house") return [True, 6] elif second.lower() == ("go southwest"): return [True, 2] elif second.lower() == ("read leaflet"): if items.useItem('leaflet', itemList): print("---------------------------------------------------------") print( "Welcome to the Unofficial Python Version of Zork. Your mission is to find a Jade Statue." ) return [True, 0] else: return [True, 0] elif second.lower() == ("kick the bucket"): print("---------------------------------------------------------") print("You die.") print("---------------------------------------------------------") return [False, 0] elif second[0:8].lower() == ("put down"): if second[9:].lower() in itemList: items.put_down(second[9:], 0) return [True, 0] else: return [True, 0] else: print("---------------------------------------------------------") return [True, 0]
def ForestRoom(forest_inp): alive = True room_num = 8 if 'pick up' in forest_inp.lower(): item = (forest_inp.lower())[8:] items.pick_up(item, room_num) elif 'put down' in forest_inp.lower(): item = (forest_inp.lower())[9:] items.put_down(item, room_num) elif 'use' in forest_inp.lower(): item = (forest_inp.lower())[4:] items.useItem(item) elif forest_inp.lower() == 'show inventory' or forest_inp.lower() == 'inventory': print("---------------------------------------------------------") print(*items.inventory, sep = ', ') elif forest_inp.lower() == ("go west"): print("---------------------------------------------------------") print("You would need a machete to go further west.") elif forest_inp.lower() == ("go north"): print("---------------------------------------------------------") print("The forest becomes impenetrable to the North.") elif forest_inp.lower() == ("go south"): print("---------------------------------------------------------") print("Storm-tossed trees block your way.") elif forest_inp.lower() == ("go east"): room_num = 9 elif forest_inp.lower() == ("go northeast"): room_num = 4 elif forest_inp.lower() == ("kick the bucket"): alive = False else: print("---------------------------------------------------------") return [room_num, alive]
def MazeInteriorRoom(maze_interior_inp, itemList): if maze_interior_inp.lower() == ("go north"): return [True, 9] else: if items.useItem("lantern", itemList): print("---------------------------------------------------------") print("You see the grue and flee before you are killed") return [True, 9] else: print("---------------------------------------------------------") print("You die.") print("---------------------------------------------------------") return [False, 0]
def room7(user_input): room = 7 print("---------------------------------------------------------") if user_input == ("go north"): print("You escaped the maze, something was off about that place.") room = 6 else: if items.useItem('lantern',inventory): print('You see the grue! Wanting to avoid trouble you leave the maze.') room = 6 elif items.useItem('gold ring', inventory): print('The little gold ring you were fingering in your pocket slips onto your finger!\n You see the grue in the distance, wanting to avoid conflict you leave the maze.') room = 6 else: print("You were eaten by the grue! You should've left the maze while you had the chance.") print("---------------------------------------------------------") print("You die.") print("---------------------------------------------------------") ded() return room
def GratingLoop(cave_inp, itemList): if cave_inp.lower() == ("descend staircase"): return [True, 5] elif cave_inp.lower() == ("take skeleton"): print("---------------------------------------------------------") print("Why would you do that? Are you some sort of sicko?") return [True, 4] elif cave_inp.lower() == ("smash skeleton"): print("---------------------------------------------------------") print("Sick person. Have some respect mate.") return [True, 4] elif cave_inp.lower() == ("light up room"): if items.useItem("lantern", itemList): print("---------------------------------------------------------") print("You light up the room and see runes on the walls.") print("They are unintelligible") return [True, 4] else: print("---------------------------------------------------------") print("You would need a torch or lamp to do that.") return [True, 4] elif cave_inp.lower() == ("break skeleton"): print("---------------------------------------------------------") print("I have two questions: Why and With What?") return [True, 4] elif cave_inp.lower() == ("go down staircase"): return [True, 5] elif cave_inp.lower() == ("go south"): return [True, 9] elif cave_inp.lower() == ("scale staircase"): return [True, 5] elif cave_inp[0:4].lower() == ("take"): return [True, 4, items.pick_up(cave_inp[5:], 4)] elif cave_inp.lower() == ("kick the bucket"): print("---------------------------------------------------------") print("You die.") print("---------------------------------------------------------") return [False, 0] elif cave_inp[0:8].lower() == ("put down"): if cave_inp[9:].lower() in itemList: items.put_down(cave_inp[9:], 4) return [True, 4] else: return [True, 4] else: print("---------------------------------------------------------") return [True, 4]
def MazeInterior(maze_inp): alive = True room_num = 3 global lit global grue if 'pick up' in maze_inp.lower(): item = (maze_inp.lower())[8:] items.pick_up(item, room_num) elif 'put down' in maze_inp.lower(): item = (maze_inp.lower())[9:] items.put_down(item, room_num) elif 'use' in maze_inp.lower(): item = (maze_inp.lower())[4:] if items.useItem(item): if item == 'lantern': lit = True elif maze_inp.lower() == 'show inventory' or maze_inp.lower() == 'inventory': print("---------------------------------------------------------") print(*items.inventory, sep = ', ') elif maze_inp.lower() == ("go north"): room_num = 2 elif maze_inp.lower() == ("kick the bucket"): alive = False elif not grue: if not lit: print("---------------------------------------------------------") print("The Grue found you and ate you!") alive = False else: print("---------------------------------------------------------") print("The Grue found you!") print("You must run away to avoid being eaten!") grue = True elif grue and maze_inp.lower() == ("run away"): room_num = 2 else: print("---------------------------------------------------------") print("The Grue found you and ate you!") alive = False return [room_num, alive]
def MazeEntrance(maze_inp): alive = True room_num = 2 global lit global ladder if 'pick up' in maze_inp.lower(): item = (maze_inp.lower())[8:] items.pick_up(item, room_num) if item == 'ladder': ladder = False elif 'put down' in maze_inp.lower(): item = (maze_inp.lower())[9:] items.put_down(item, room_num) elif 'use' in maze_inp.lower(): item = (maze_inp.lower())[4:] if items.useItem(item): if item == 'lantern': lit = True elif maze_inp.lower() == 'show inventory' or maze_inp.lower() == 'inventory': print("---------------------------------------------------------") print(*items.inventory, sep = ', ') elif maze_inp.lower() == 'explore' or maze_inp.lower() == 'explore cavern': if not ladder: print("---------------------------------------------------------") print("You explore the cavern and find nothing.") else: print("---------------------------------------------------------") print("You explore the cavern and find a ladder hidden in the far corner.") elif maze_inp.lower() == ("go north"): room_num = 10 elif maze_inp.lower() == ("go south"): room_num = 3 elif maze_inp.lower() == ("kick the bucket"): alive = False else: print("---------------------------------------------------------") return [room_num, alive]
def OgreClearing(ogre_inp): alive = True room_num = 12 global offering global ogre if 'pick up' in ogre_inp.lower(): item = (ogre_inp.lower())[8:] if item == 'key': if not ogre: items.pick_up(item, room_num) else: print("You have not pacified the ogre.") else: items.pick_up(item, room_num) elif 'put down' in ogre_inp.lower(): item = (ogre_inp.lower())[9:] items.put_down(item, room_num) elif 'use' in ogre_inp.lower(): item = (ogre_inp.lower())[4:] if items.useItem(item): if item == 'fish': offering = True elif ogre_inp.lower() == 'show inventory' or ogre_inp.lower() == 'inventory': print("---------------------------------------------------------") print(*items.inventory, sep = ', ') elif ogre_inp.lower() == ("go north"): room_num = 9 elif ogre_inp.lower() == ("escape"): room_num = 9 elif ogre_inp.lower() == ("kill ogre") or ogre_inp.lower() == ("fight ogre"): print("---------------------------------------------------------") print("You have nothing you can harm the ogre with.") print("The ogre ate you!") alive = False elif ogre_inp.lower() == ("steal key") or ogre_inp.lower() == ("take key"): print("---------------------------------------------------------") print("You have nothing you can harm the ogre with.") print("The ogre ate you!") alive = False elif ogre_inp.lower() == ("befriend ogre"): print("---------------------------------------------------------") if offering: print("You befriended the ogre by giving the ogre the fish!") print("In return the ogre gave you the key.") (items.inventory).remove('fish') ogre = False else: print("---------------------------------------------------------") print("You have nothing to befriend the ogre with.") print("The ogre ate you!") alive = False elif ogre_inp.lower() == ("kick the bucket"): alive = False else: print("---------------------------------------------------------") return [room_num, alive]
def CaveRoom(cave_inp): alive = True room_num = 10 global lit global height global note global midway if 'pick up' in cave_inp.lower(): item = (cave_inp.lower())[8:] if item == 'note': if lit or midway: items.pick_up(item, room_num) note = True else: print("No such item is visible.") else: items.pick_up(item, room_num) elif 'put down' in cave_inp.lower(): item = (cave_inp.lower())[9:] items.put_down(item, room_num) elif 'use' in cave_inp.lower(): item = (cave_inp.lower())[4:] if items.useItem(item): if item == 'lantern': lit = True if item == 'ladder': height = True elif cave_inp.lower() == 'show inventory' or cave_inp.lower() == 'inventory': print("---------------------------------------------------------") print(*items.inventory, sep = ', ') elif cave_inp.lower() == ("go up") or cave_inp.lower() == ("ascend grating") or cave_inp.lower() == ("go up grating"): if height: room_num = 9 else: print("---------------------------------------------------------") print("You cannot jump high enough to escape.") elif cave_inp.lower() == ("descend staircase") or cave_inp.lower() == ("go down stairs"): room_num = 11 elif cave_inp.lower() == ("go south"): room_num = 2 elif cave_inp.lower() == ("take skeleton"): print("---------------------------------------------------------") print("Why would you do that? Are you some sort of sicko?") elif cave_inp.lower() == ("smash skeleton"): print("---------------------------------------------------------") print("Sick person. Have some respect mate.") elif cave_inp.lower() == ("light up room"): print("---------------------------------------------------------") print("You would need a torch or lamp to do that.") elif cave_inp.lower() == ("break skeleton"): print("---------------------------------------------------------") print("I have two questions: Why and With What?") elif cave_inp.lower() == ("inspect skeleton"): print("---------------------------------------------------------") print("Upon further inspection the skeleton appears to be holding a note.") midway = True elif cave_inp.lower() == ("go down staircase"): room_num = 11 elif cave_inp.lower() == ("scale staircase"): room_num = 11 elif cave_inp.lower() == ("read note"): if note: print("---------------------------------------------------------") print("BEWARE THE MAZE") print("THE MAZE BRINGS ONLY DEATH AT THE HANDS OF THE GRUE") print("ESCAPE ONLY FROM WHENCE YOU CAME") print() print("THE KEY IS NOT IN THE MAZE") else: print("---------------------------------------------------------") print("Note is not in inventory") elif cave_inp.lower() == ("kick the bucket"): alive = False else: print("---------------------------------------------------------") return [room_num, alive]
def FrontOfHouse(second): global leaf global leaflet alive = True room_num = 4 if 'pick up' in second.lower(): item = (second.lower())[8:] if item == 'leaflet' and leaf: leaflet = False items.pick_up(item, room_num) elif item == 'leaflet' and not leaf: print("---------------------------------------------------------") print("Must open the mailbox to retrieve the leaflet.") else: items.pick_up(item, room_num) elif 'put down' in second.lower(): item = (second.lower())[9:] items.put_down(item, room_num) if item == 'leaflet': leaflet = True elif 'use' in second.lower(): item = (second.lower())[4:] items.useItem(item) elif second.lower() == 'show inventory' or second.lower() == 'inventory': print("---------------------------------------------------------") print(*items.inventory, sep = ', ') elif second.lower() == ("take mailbox"): print("---------------------------------------------------------") print("It is securely anchored.") elif second.lower() == ("open mailbox"): if leaflet: print("---------------------------------------------------------") print("Opening the small mailbox reveals a leaflet.") else: print("---------------------------------------------------------") print("Mailbox is empty.") leaf = True elif second.lower() == ("go north"): room_num = 1 elif second.lower() == ("go east"): room_num = 5 elif second.lower() == ("open door"): print("---------------------------------------------------------") print("The door cannot be opened.") elif second.lower() == ("follow path"): print("---------------------------------------------------------") print("Go which direction?") elif second.lower() == ("take boards") or second.lower() == ("break boards"): print("---------------------------------------------------------") print("The boards are securely fastened.") elif second.lower() == ("look at house"): print("---------------------------------------------------------") print("The house is a beautiful colonial house which is painted white. It is clear that the owners must have been extremely wealthy.") elif second.lower() == ("go southwest"): room_num = 8 elif second.lower() == ("read leaflet"): if not leaf: print("---------------------------------------------------------") print("Must open the mailbox to read the leaflet.") else: if 'leaflet' in items.inventory: print("---------------------------------------------------------") print("Welcome to the Unofficial Python Version of Zork. Your mission is to find a Jade Statue.") else: print("---------------------------------------------------------") print("You must pick up the leaflet to read the leaflet.") elif second.lower() == ("kick the bucket"): alive = False else: print("---------------------------------------------------------") return [room_num, alive]