Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.06 KB | None | 0 0
  1. def story():
  2.     room1Fr = {"test" : False}
  3.  
  4.     room1()
  5.  
  6.  
  7.  
  8. def room1():
  9.     """
  10.    This is room-1
  11.    """
  12.     def riddle1():
  13.         """
  14.        Riddle of the first room
  15.        """
  16.         from random import randint
  17.         print("\nThe lock on the door is activated by saying a number out loud!")
  18.         correctAnswer = 1000
  19.         randomCombination = 42
  20.         while correctAnswer != randomCombination:
  21.             correctAnswer1 = input("Try a number: ")
  22.             if int(correctAnswer1) == randomCombination:
  23.                 print("Congratulations, you guess the correct number:", randomCombination)
  24.                 print("You have managed the open the door and get to the next room")
  25.                 break
  26.             elif int(correctAnswer1) > randomCombination:
  27.                 print("The combination number is Lower")
  28.             elif int(correctAnswer1) < randomCombination:
  29.                 print("The combination number is higher")
  30.             else:
  31.                 print("Thats not a number, try again")
  32.  
  33.     def room1Clue():
  34.         """
  35.        Get clues on how to finish the room
  36.        """
  37.         print("1) Play the riddle game to move on to the next room")
  38.  
  39.        
  40.     def room1Help():
  41.         """
  42.        Gives help commands for room 1
  43.        """
  44.         print("""You can use the commands:
  45.              Riddle               Gets the riddle of the room
  46.              search <object>      Search objects
  47.              i/info               Get information about the room
  48.              bk/back              Go Back
  49.              fr/forward           Go forward
  50.              see                  Look around the room
  51.              c/clue               Get a clue\n""")
  52.        
  53.     gameMaster = "\nHello player I'm  your gamemaster, you may call me Glados"
  54.  
  55.     roomLayout = '''\nWelcome to room-1, there is 2 objects in this room!\nThe room looks like this:
  56.    """""""--"""""""
  57.    " WC "         "
  58.    """"""         "
  59.    "              "
  60.    """""          "
  61.    " B "          "
  62.    " E "          "
  63.    " D "          "
  64.    """"""""""""""""'''
  65.     print(roomLayout, gameMaster)
  66.  
  67.     room1Answer = False
  68.     choice = ""
  69.     while room1Answer != True:
  70.         choice = input("What would you like to do?: ")
  71.         if choice == "riddle":
  72.             riddle1()
  73.             room1fr["test"] = True
  74.             room1Answer = True
  75.         elif choice == "i" or choice == "info":
  76.             print(roomLayout)
  77.         elif choice == "h" or choice == "help":
  78.             room1Help()
  79.         elif choice == "fr" or choice == "forward":
  80.             if room1fr["test"] == True: # Det här funkar inte
  81.                 print("Moving up to room-2")
  82.                 room2()
  83.             else:
  84.                 print("You need to finish this room first!")  
  85.         elif choice == "bk" or choice == "back":
  86.             print("You're in the first room you cant go back!")
  87.         elif choice == "see":
  88.             print("You see a WC and a BED and a door, try searching the wc/bed!")
  89.         elif choice == "c" or choice == "clue":
  90.             room1Clue()
  91.  
  92.         elif "search" in choice:
  93.             if "bed" in choice:
  94.                 print("\nYou searched the bed and found nothing\n")
  95.             elif "wc" in choice:
  96.                 print("\nYou searched the WC and found a calculator")
  97.                 print("Added calculator to your backpack\n")
  98.             else:
  99.                 print("You cant search that, try: search bed/search wc")
  100.         else:
  101.             print("Write h/help to get command list")
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109. Traceback (most recent call last):
  110.   File "C:\cygwin64\dbwebb-kurser\python\me\kmom10\adventure\adventure.py", line 104, in <module>
  111.     main()
  112.   File "C:\cygwin64\dbwebb-kurser\python\me\kmom10\adventure\adventure.py", line 99, in main
  113.     story()
  114.   File "C:\cygwin64\dbwebb-kurser\python\me\kmom10\adventure\main.py", line 9, in story
  115.     room1()
  116.   File "C:\cygwin64\dbwebb-kurser\python\me\kmom10\adventure\main.py", line 79, in room1
  117.     room1fr["test"] = True
  118. NameError: name 'room1fr' is not defined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement