Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- places_to_visit_in_hallway = ('upper', 'lower', 'room1', 'room2', 'room3', 'room4')
- valid_places_for_room1 = ('sofa', 'table', 'TV', 'Playstation4', 'bookshelf')
- location = 'hallway'
- command = ''
- commandarray = command.split()
- inventory = []
- entrance_map = ('|Livingroom|', '|', 'Hallway', '|', '|Kitchen|\n',
- '|Hallway|', ' ', ' ' '|'' Hallway', '|', '|Hallway|\n',
- '|Diningroom|', '|', 'Entrance', '|', '|Family Room|\n'
- )
- help = ('If you are outside a room:\n'
- 'Type - go to and state a destination\n'
- 'If you are inside a room:\n'
- 'Type - go to and state a destination\n'
- 'or\n'
- 'Type - take and specify what\n'
- 'If you are inside or outside a room:\n'
- 'Type - map - shows you the surroundings\n'
- 'Type - inventory - shows you what your inventory contains\n'
- 'Type - go to upper/lower if you want to change to floor\n'
- 'If you are inside a room:\n'
- 'Type - leave to leave the room\n'
- 'If you are outside a room:'
- 'Type - exit to leave the game')
- class InputHandler:
- @staticmethod
- def Input():
- command = input()
- commandarray = command.split()
- return commandarray
- @staticmethod
- def check_input(location, commandarray):
- if location == "hallway":
- if commandarray[0] == 'HELP':
- print("({})".format("".join(help)))
- return True
- elif commandarray[2] == 'upper':
- return False
- if commandarray[0] == 'go':
- FirstFloor.go_function(commandarray)
- return True
- elif commandarray[0] == 'map':
- print("({})".format("".join(entrance_map)))
- return True
- elif commandarray[0] == 'inventory':
- print(inventory)
- return True
- elif commandarray[0] == 'exit':
- return False
- else:
- print("You have entered a invalid command!")
- return False
- if location == 'room1':
- FirstFloor.entering_Room_one()
- if location == 'room2':
- FirstFloor.entering_Room_two()
- if location == 'room3':
- FirstFloor.entering_Room_three()
- if location == 'room4':
- FirstFloor.entering_Room_four()
- class FirstFloor:
- def __init__(self, inventory, location):
- self.inventory = inventory
- self.location = location
- @staticmethod
- def floor_message():
- print("WELCOME PLAYER ! You are currently on the first\n"
- "floor and this is where your journey begins\n"
- "I wish you good luck and have fun !\n"
- "Start playing by typing a desired command\n"
- "if you don't know what to type, please type\n"
- "'HELP' to check the commands.")
- @staticmethod
- def handle_desk():
- print("You come to the desk and look\n"
- "at the computer, but it only has\n"
- "ubuntu on it, so you can't even\n"
- "play some game on it...")
- print("What do you want to do now?")
- command = InputHandler.Input()
- FirstFloor.action_in_fourth_room(command)
- @staticmethod
- def handle_bed():
- print("You come to the bed and see a old\n"
- "tetris on it. You play a little bit\n"
- "but it crashes, just before you can\n"
- "beat the highscore, so you get angry\n"
- "and start wanting to leave this house\n"
- "even more than before")
- print("What do you want to do now ?")
- command = InputHandler.Input()
- FirstFloor.action_in_fourth_room(command)
- @staticmethod
- def entering_Room_four():
- print("Do you wish to enter the room ?\n"
- "Yes or No")
- command = input()
- if command == 'Yes':
- location = "room4"
- print("Once in the fourth room\n"
- "you see a bed on your left\n"
- "in front of the bed there is a\n"
- "desk with a computer on it")
- fourth_room_commands = InputHandler.Input()
- FirstFloor.action_in_fourth_room(fourth_room_commands)
- else:
- print("Are you sure you don't want to enter ?\n"
- "Yes or No ? for the last time..")
- command = input()
- if command == 'Yes':
- print("Ok, you are going back to the Hallway")
- print("What do you wish to do now ?")
- location = 'hallway'
- variable = InputHandler.Input()
- InputHandler.check_input(location, variable)
- else:
- print("Once in the fourth room\n"
- "you see a bed on your left\n"
- "in front of the bed there is a\n"
- "desk with a computer on it")
- print("What do you chose to do now ?")
- fourth_room_commands = InputHandler.Input()
- FirstFloor.action_in_fourth_room(fourth_room_commands)
- @staticmethod
- def action_in_fourth_room(fourth_room_commands):
- valid_places = ('bed', 'desk')
- while(FirstFloor.check_commands_for_fourth_room(fourth_room_commands, valid_places)==True):
- command = input()
- fourth_room_commands = command.split()
- @staticmethod
- def check_commands_for_fourth_room(fourth_room_commands,valid_places):
- if fourth_room_commands[0] == 'HELP':
- print("({})".format("".join(help)))
- return True
- if fourth_room_commands[0] == 'leave':
- print("You have left the room\n"
- "and are back in the hallway\n"
- "what do you want to do now ?")
- return False
- if fourth_room_commands[0] == 'map':
- print("Once in the fourth room\n"
- "you see a bed on your left\n"
- "in front of the bed there is a\n"
- "desk with a computer on it")
- return True
- if fourth_room_commands[0] == 'inventory':
- print(inventory)
- return True
- if len(fourth_room_commands) < 2:
- print("You didn't enter enough commands.\n"
- "Please type HELP if you don't know what to type!")
- return False
- elif len(fourth_room_commands) == 2:
- if fourth_room_commands[1] == 'to':
- print("You didn't state your destination!\n"
- "Please state where you want to go!")
- return True
- else:
- print("Invalid command! Please type HELP if you don't know the commands!")
- elif len(fourth_room_commands) == 3:
- if fourth_room_commands[2] in valid_places:
- print("You are going to " + fourth_room_commands[2])
- if fourth_room_commands[2] == 'bed':
- FirstFloor.handle_bed()
- return False
- elif fourth_room_commands[2] == 'desk':
- FirstFloor.handle_desk()
- return False
- else:
- print("You have entered a invalid third statement.\n"
- "Maybe you meant to write: bed\n"
- "desk")
- return True
- else:
- print("You have entered a invalid second statement.\n"
- "Maybe you meant to write: to")
- return False
- @staticmethod
- def handle_inflatablebed():
- print("You come to the bed and look around\n"
- "it but you don't notice anything special,\n"
- "besides the fact of how smelly it is..")
- print("What do you want to do now?")
- command = InputHandler.Input()
- FirstFloor.action_in_third_room(command)
- @staticmethod
- def entering_Room_three():
- print("Do you wish to enter the room ?\n"
- "Yes or No")
- command = input()
- if command == 'Yes':
- location = "room3"
- print("Once in the third room\n"
- "you notice that there is only a\n"
- "inflatable bed on the middle of the room")
- third_room_commands = InputHandler.Input()
- FirstFloor.action_in_third_room(third_room_commands)
- else:
- print("Are you sure you don't want to enter ?\n"
- "Yes or No ? for the last time..")
- command = input()
- if command == 'Yes':
- print("Ok, you are going back to the Hallway")
- print("What do you wish to do now ?")
- location = 'hallway'
- variable = InputHandler.Input()
- InputHandler.check_input(location, variable)
- else:
- print("Once in the third room\n"
- "you notice that there is only a\n"
- "inflatable bed on the middle of the room")
- print("What do you chose to do now ?")
- third_room_commands = InputHandler.Input()
- FirstFloor.action_in_third_room(third_room_commands)
- @staticmethod
- def action_in_third_room(third_room_commands):
- valid_places = ('inflatablebed')
- while(FirstFloor.check_commands_for_third_room(third_room_commands, valid_places)==True):
- command = input()
- third_room_commands = command.split()
- @staticmethod
- def check_commands_for_third_room(third_room_commands,valid_places):
- if third_room_commands[0] == 'HELP':
- print("({})".format("".join(help)))
- return True
- if third_room_commands[0] == 'leave':
- print("You have left the room\n"
- "and are back in the hallway\n"
- "what do you want to do now ?")
- return False
- if third_room_commands[0] == 'map':
- print("Once in the third room\n"
- "you notice that there is only a\n"
- "inflatable bed on the middle of the room")
- return True
- if third_room_commands[0] == 'inventory':
- print(inventory)
- return True
- if len(third_room_commands) < 2:
- print("You didn't enter enough commands.\n"
- "Please type HELP if you don't know what to type!")
- return False
- elif len(third_room_commands) == 2:
- if third_room_commands[1] == 'to':
- print("You didn't state your destination!\n"
- "Please state where you want to go!")
- return True
- else:
- print("Invalid command! Please type HELP if you don't know the commands!")
- elif len(third_room_commands) == 3:
- if third_room_commands[2] in valid_places:
- print("You are going to " + third_room_commands[2])
- if third_room_commands[2] == 'inflatablebed':
- FirstFloor.handle_inflatablebed()
- return False
- else:
- print("You have entered a invalid third statement.\n"
- "Maybe you meant to write: inflatablebed")
- return True
- else:
- print("You have entered a invalid second statement.\n"
- "Maybe you meant to write: to")
- return False
- @staticmethod
- def handle_oven():
- if "SecondRoom-Key" in inventory:
- print("You already came here and took\n"
- "the key... What more do you want from\n"
- "an oven ?")
- print("What do you want to do now?")
- command = InputHandler.Input()
- FirstFloor.action_in_second_room(command)
- else:
- print("The oven is a bit rusty so\n"
- "you can't see inside, do you\n"
- "wish to open it ?")
- command = input("Yes or No?: ")
- if command == "Yes":
- print("You open the oven and find\n"
- "a key.")
- command = input("Do you wish to take it? Yes/No ?")
- if command == "Yes":
- print("You took this key inside your inventory !\n"
- "You can now check your inventory to see\n"
- "the items inside!")
- inventory.append("SecondRoom-Key")
- print("What do you want to do now?")
- command = InputHandler.Input()
- FirstFloor.action_in_second_room(command)
- else:
- print("Well ok, what do you want to do now, crazy head ?")
- command = InputHandler.Input()
- FirstFloor.action_in_second_room(command)
- else:
- print("Ok, what do you want to do now ?")
- command = InputHandler.Input()
- FirstFloor.action_in_second_room(command)
- @staticmethod
- def handle_secondtable():
- print("You come to the table and see\n"
- "that it has some writing carved\n"
- "on it. You read the following:"
- "\"What is useful, but burns when,\n"
- "you're not careful\"")
- print("What do you wish to do now ?")
- command = InputHandler.Input()
- FirstFloor.action_in_second_room(command)
- @staticmethod
- def handle_drawers():
- print("You come to drawers and open\n"
- "each one, but the only things\n"
- "you can find are knives and forks\n")
- command = input("Do you wish to take one of the knives ? Yes/No?")
- if command == "Yes":
- #this knife will be used on the last floor to open the easter egg
- print("Ok, now you have your knife in your inventory")
- inventory.append("knive")
- print("What do you want to do now?")
- command = InputHandler.Input()
- FirstFloor.action_in_second_room(command)
- else:
- print("Ok, then, what do you want to do now ?")
- command = InputHandler.Input()
- FirstFloor.action_in_second_room(command)
- @staticmethod
- def handle_washingmachine():
- print("You come to the washing machine\n"
- "and manage to open it, but unfortunately\n"
- "as you expected, you find nothing other than\n"
- "dirty dishes")
- print("What do you want to do now?")
- command = InputHandler.Input()
- FirstFloor.action_in_second_room(command)
- @staticmethod
- def entering_Room_two():
- print("Do you wish to enter the room ?\n"
- "Yes or No")
- command = input()
- if command == 'Yes':
- location = "room2"
- print("Once in the second room you look around\n"
- "and see a table in the middle of the room\n"
- "and on your right you have a couple of\n"
- "half closed drawers, on your left there\n"
- "is a oven and washing machine")
- second_room_commands = InputHandler.Input()
- FirstFloor.action_in_second_room(second_room_commands)
- else:
- print("Are you sure you don't want to enter ?\n"
- "Yes or No ? for the last time..")
- command = input()
- if command == 'Yes':
- print("Ok, you are going back to the Hallway")
- print("What do you wish to do now ?")
- location = 'hallway'
- variable = InputHandler.Input()
- InputHandler.check_input(location, variable)
- else:
- print("Once in the second room you look around\n"
- "and see a table in the middle of the room\n"
- "and on your right you have a couple of\n"
- "half closed drawers, on your left there\n"
- "is a oven and washing machine")
- print("What do you chose to do now ?")
- second_room_commands = InputHandler.Input()
- FirstFloor.action_in_second_room(second_room_commands)
- @staticmethod
- def action_in_second_room(second_room_commands):
- valid_places = ('drawers','table','washingmachine','oven')
- while(FirstFloor.check_commands_for_second_room(second_room_commands, valid_places)==True):
- command = input()
- second_room_commands = command.split()
- @staticmethod
- def check_commands_for_second_room(second_room_commands,valid_places):
- if second_room_commands[0] == 'HELP':
- print("({})".format("".join(help)))
- return True
- if second_room_commands[0] == 'leave':
- print("You have left the room\n"
- "and are back in the hallway\n"
- "what do you want to do now ?")
- return False
- if second_room_commands[0] == 'map':
- print("Once in the second room you look around\n"
- "and see a table in the middle of the room\n"
- "and on your right you have a couple of\n"
- "half closed drawers, on your left there\n"
- "is a oven and washing machine")
- return True
- if second_room_commands[0] == 'inventory':
- print(inventory)
- return True
- if len(second_room_commands) < 2:
- print("You didn't enter enough commands.\n"
- "Please type HELP if you don't know what to type!")
- return False
- elif len(second_room_commands) == 2:
- if second_room_commands[1] == 'to':
- print("You didn't state your destination!\n"
- "Please state where you want to go!")
- return True
- else:
- print("Invalid command! Please type HELP if you don't know the commands!")
- elif len(second_room_commands) == 3:
- if second_room_commands[2] in valid_places:
- print("You are going to " + second_room_commands[2])
- if second_room_commands[2] == 'oven':
- FirstFloor.handle_oven()
- return False
- elif second_room_commands[2] == 'table':
- FirstFloor.handle_secondtable()
- return False
- elif second_room_commands[2] == 'drawers':
- FirstFloor.handle_drawers()
- return False
- elif second_room_commands[2] == 'washingmachine':
- FirstFloor.handle_washingmachine()
- return False
- else:
- print("You have entered a invalid third statement.\n"
- "Maybe you meant to write: table\n"
- "drawers\n"
- "oven\n"
- "washingmachine\n")
- return True
- else:
- print("You have entered a invalid second statement.\n"
- "Maybe you meant to write: to")
- return False
- @staticmethod
- def handle_sofa():
- print("You look around the sofa, but\n"
- "unfortunately there seems to be\n"
- "no clues here")
- print("What do you wish to do now ?")
- first_room_commands = InputHandler.Input()
- FirstFloor.action_in_first_room(first_room_commands)
- @staticmethod
- def handle_table():
- print("You came to the table and\n"
- "took the letter from it.\n"
- "Once you open the letter,\n"
- "you find the following message: \n"
- "\"Get busy living or get busy dying\"")
- print("Hmmm.. this seems to be some sort of a clue..")
- print("What do you wish to do now?")
- first_room_commands = InputHandler.Input()
- FirstFloor.action_in_first_room(first_room_commands)
- @staticmethod
- def handle_TV():
- print("You came to look at the TV\n"
- "but unfortunately there isn't \n"
- "any clue here..")
- print("What do you wish to do now?")
- first_room_commands = InputHandler.Input()
- FirstFloor.action_in_first_room(first_room_commands)
- @staticmethod
- def handle_playstation():
- print("You came to look at the PS\n"
- "but you saw that it had only \n"
- "fifa 2019, so it was in no interest\n"
- "to you..")
- print("What do you wish to do now?")
- first_room_commands = InputHandler.Input()
- FirstFloor.action_in_first_room(first_room_commands)
- @staticmethod
- def handle_bookshelf():
- print("You come to the bookshelf and see\n"
- "a couple of books. The authors of the \n"
- "books are \"Stephen King\",\n"
- "\"Hamlet\", \"Ivan Vazov\"")
- print("Do you wish to grab one of the books ?")
- command = input("Yes or No ? ")
- if command == 'Yes':
- print("Which author's book do you wish to grab ?")
- command = input("Type Stephen or Hamlet or Ivan Vazov")
- if command == 'Stephen':
- if "clue" in inventory:
- print("You already opened King's\n"
- "book, you crazy.\n"
- "Now what is the next adequate thing you want to do ?")
- command = InputHandler.Input()
- FirstFloor.action_in_first_room(command)
- else:
- print("You opened Stephen King's book\n"
- "inside you found a key and a clue that says the following: \n"
- "\"Escape comes for those who never fear going up\"")
- print("Do you wish to take the key with you?")
- command = input("Type 'take key' if you wish to take it")
- if command =='take key':
- inventory.append('key')
- print("You can now check your inventory to see what items\n"
- "you have inside it!")
- print("What do you wish to do now ?")
- first_room_commands = InputHandler.Input()
- FirstFloor.action_in_first_room(first_room_commands)
- else:
- print("Guess you have good memory, what do you want to do now ?")
- first_room_commands = InputHandler.Input()
- FirstFloor.action_in_first_room(first_room_commands)
- else:
- print("You open the book, but find nothing special in it")
- print("What do you want to do now? You can return\n"
- "to the bookshelf to try another book")
- first_room_commands = InputHandler.Input()
- FirstFloor.action_in_first_room(first_room_commands)
- else:
- print("Ok then, what do you wish to do now ?")
- first_room_commands = InputHandler.Input()
- FirstFloor.action_in_first_room(first_room_commands)
- @staticmethod
- def go_function(commandarray):
- if len(commandarray) < 2:
- print("You didn't enter enough commands.\n"
- "Please type HELP if you don't know what to type!")
- return False
- elif len(commandarray) == 2:
- if commandarray[1] == 'to':
- print("You didn't state your destination!\n"
- "Please state where you want to go!")
- return True
- else:
- print("Invalid command! Please type HELP if you don't know the commands!")
- elif len(commandarray) == 3:
- if commandarray[2] == 'upper':
- if 'key' in inventory:
- print("Ok you are going to the second floor")
- return False
- else:
- print("You have to find the key for the second\n"
- "floor, before you can go there")
- return True
- if commandarray[2] == 'lower':
- if 'basement-key' in inventory:
- print("Ok you are going to the basement")
- return False
- else:
- print("You have to find the key for the basement,\n"
- "before you can go there")
- return True
- if commandarray[2] in places_to_visit_in_hallway:
- print("You are going to " + commandarray[2])
- location = commandarray[2]
- InputHandler.check_input(location, commandarray[2])
- return True
- else:
- print("You have entered a invalid third statement.\n"
- "Maybe you meant to write: upper\n"
- "lower\n"
- "first room->room1\n"
- "second room->room2\n"
- "third room->room3\n"
- "fourth room->room4")
- return True
- else:
- print("You have entered a invalid second statement.\n"
- "Maybe you meant to write: to")
- return False
- @staticmethod
- def entering_Room_one():
- print("Do you wish to enter the room ?\n"
- "Yes or No")
- command = input()
- if command == 'Yes':
- location = 'room1'
- print("You have entered the first room!\n"
- "In front of you, on the left side of the room,\n"
- "there is a sofa with a coffee table\n"
- "in front of it. On the right of the room\n"
- "in front of the coffee table there is a\n"
- "playstation4 with a TV. At the end of the room\n"
- "right in front of you, there is a book shelf.\n"
- "The first thing you notice is that there is a\n"
- "LETTER on the coffe table")
- print("What do you chose to do now ?")
- first_room_commands = InputHandler.Input()
- FirstFloor.action_in_first_room(first_room_commands)
- else:
- print("Are you sure you don't want to enter ?\n"
- "Yes or No ? for the last time..")
- command = input()
- if command == 'Yes':
- print("Ok, you are going back to the Hallway")
- print("What do you wish to do now ?")
- location = 'hallway'
- variable = InputHandler.Input()
- InputHandler.check_input(location, variable)
- else:
- print("You have entered the first room!\n"
- "In front of you, on the left side of the room,\n"
- "there is a sofa with a coffee table\n"
- "in front of it. On the right of the room\n"
- "in front of the coffee table there is a\n"
- "playstation4 with a TV. At the end of the room\n"
- "right in front of you, there is a book shelf.\n"
- "The first thing you notice is that there is a\n"
- "LETTER on the coffe table")
- print("What do you chose to do now ?")
- first_room_commands = InputHandler.Input()
- FirstFloor.action_in_first_room(first_room_commands)
- @staticmethod
- def action_in_first_room(first_room_commands):
- valid_places = ('sofa','table','TV','Playstation4','bookshelf')
- while(FirstFloor.check_commands_for_first_room(first_room_commands, valid_places)==True):
- command = input()
- first_room_commands = command.split()
- @staticmethod
- def check_commands_for_first_room(first_room_commands,valid_places):
- if first_room_commands[0] == 'HELP':
- print("({})".format("".join(help)))
- return True
- if first_room_commands[0] == 'leave':
- print("You have left the room\n"
- "and are back in the hallway\n"
- "what do you want to do now ?")
- return False
- if first_room_commands[0] == 'map':
- print("You have entered the first room!\n"
- "In front of you, on the left side of the room,\n"
- "there is a sofa with a coffee table\n"
- "in front of it. On the right of the room\n"
- "in front of the coffee table there is a\n"
- "playstation4 with a TV. At the end of the room\n"
- "right in front of you, there is a book shelf.\n"
- "The first thing you notice is that there is a\n"
- "LETTER on the coffe table")
- return True
- if first_room_commands[0] == 'inventory':
- print(inventory)
- return True
- if len(first_room_commands) < 2:
- print("You didn't enter enough commands.\n"
- "Please type HELP if you don't know what to type!")
- return False
- elif len(first_room_commands) == 2:
- if first_room_commands[1] == 'to':
- print("You didn't state your destination!\n"
- "Please state where you want to go!")
- return True
- else:
- print("Invalid command! Please type HELP if you don't know the commands!")
- elif len(first_room_commands) == 3:
- if first_room_commands[2] in valid_places:
- print("You are going to " + first_room_commands[2])
- if first_room_commands[2] == 'sofa':
- FirstFloor.handle_sofa()
- return False
- elif first_room_commands[2] == 'table':
- FirstFloor.handle_table()
- return False
- elif first_room_commands[2] == 'TV':
- FirstFloor.handle_TV()
- return False
- elif first_room_commands[2] == 'bookshelf':
- FirstFloor.handle_bookshelf()
- return False
- elif first_room_commands[2] == 'Playstation4':
- FirstFloor.handle_playstation()
- return False
- else:
- print("You have entered a invalid third statement.\n"
- "Maybe you meant to write: sofa\n"
- "table\n"
- "bookshelf\n"
- "TV\n"
- "Playstation4\n")
- return True
- else:
- print("You have entered a invalid second statement.\n"
- "Maybe you meant to write: to")
- return False
- FirstFloor(inventory, location).floor_message()
- variable = InputHandler.Input()
- secondvariable = InputHandler.check_input(location, variable)
- while(secondvariable == True):
- variable = InputHandler.Input()
- secondvariable = InputHandler.check_input(location, variable)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement