# create a class called chapter class chapter(object): # create its __init__ method, to which the start chapter text is passed def __init__(self, start_chapter_text): # store it in a variable self.start_chapter_text = start_chapter_text # create a function to print it def print_start_chapter_text(self): # print it print(self.start_chapter_text) # make a scene class class scene(object): # create its init function to which the scene text, A list of choices, and the next scene are passed def __init__(self, scene_text, choice): self.scene_text = scene_text self.choices = choice # create the print_scene method, it prints the scene text def print_scene(self): # print it print(self.scene_text) # creat a get_choices method which gives you the choices def get_choices(self): # return it return self.choices
# import needed files from classes import * # create a method that gets the user's choice def get_user_action(): # get the choice and convert it to a number choice = int(input("enter your choice:> ")) # return it return choice # create an instance of chapter, call it chapter_1 chapter_1 = chapter("chapter 1, the escape") # create an instance of chapter, call it chapter_2 chapter_2 = chapter("chapter2, the game of guess the password") # create the choices for the first and second scene choices_of_chapter_1 = "1: examin the scene more closely, 2: shout for help" choices_2_of_chapter_1 = "1: read the note, 2: leave it" # create the scenes, pass the constructer the scene text and the choices scene_1_of_chapter_1 = scene( "you do not have a clue as to how you got here, you are standing in a dark coridoor, only lit by emergency lamps.", choices_of_chapter_1, ) scene2_of_chapter_1 = scene( "you see a paper note lieing on the flore.", choices_2_of_chapter_1, ) scene1_of_chapter_2 = scene( "you walk slowly in to the room, getting closer to the computer, you see that the computer askes for a password, you give it a try, after all, you got nothing better to do", None, ) # print the text that start's chapter 1 chapter_1.print_start_chapter_text() # print the first scene scene_1_of_chapter_1.print_scene() # print its choices print(scene_1_of_chapter_1.get_choices()) # use a while loop for the game while 1: # use a try block try: # get the user action action = get_user_action() # if it is = to 1 if action == 1: # print scene 2 and it's choices scene2_of_chapter_1.print_scene() print(scene2_of_chapter_1.get_choices()) # get the user action second_action = get_user_action() # if it = 1 if second_action == 1: # print next to last scene print( "you pick up the note and read it, it reads: welcome, are you reddy, player?, with a grinding sound, the wall infrunt of you moves away reveeling a room with a computer." ) # start chapter 2 chapter_2.print_start_chapter_text() # print the first scene of chapter 2 scene1_of_chapter_2.print_scene() # ask for the password password = input("enter the password:> ") # if it is admin if password == "admin": # player wins, print the win ending print("you wone the game") print( 'you here a voice cumming from an unseen sorce, the voice says: " I told you not to set the password to admin! ", an other voice says: "let him go, we suck at building an escaperoom.' ) print("you wone") break # if the password is not admin else: # player does not win, print the other ending print( "the last sound you here is the wall mooving back, seeling you in the space" ) print("the end") break # if action for scene2 of ch 1 is = 2 elif second_action == 2: # print what happens print( "you ignore the note, but nothing seems to happen, maybe you should read it? " ) # if action for scene1 of ch 1 = 2 elif action == 2: # print it print("you shout your lungs out, but nothing happens") # if not any of them else: print("your choice should be the number 1 or the number 2") # if we do not input a number except: # ask for a number print("enter a number")