Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.31 KB | None | 0 0
  1.  
  2. # Introduction to Programming
  3. # Nicholas Blaskey
  4. # 9/27/2017
  5.  
  6. parkingLot = "You are in a parking lot of ikea. North of you is the entrance."
  7.  
  8. diningArea = ("You are in a dining room section of ikea. To your north is the"
  9. " bedroom area and east is the kitchen Area")
  10.  
  11. bedArea = ("You are in the bed room section of ikea. To your west is the"
  12. " living room area and to your east is the subway food chain"
  13. " and to your south is the dining area")
  14.  
  15. livingRoomArea = ("You are in the living room section of ikea. To your"
  16. " east is the bedroom area")
  17.  
  18. kitchenArea = ("You are in the kitchen area of ikea. To your north is"
  19. " the subway food chain and west of you is the dining "
  20. " room section")
  21.  
  22. foodArea = ("You are at a subway located inside of ikea. To your west"
  23. " is the bedroom section of ikea and south is the kitchen area.")
  24.  
  25. #vistedParking starts off true because we start the user in the parking lot
  26. vistedParking, vistedDining, vistedBed = True, False, False
  27. vistedLiving, vistedKitchen, vistedFood = False, False, False
  28. helpMessage = "Valid commands are North, West, East, South, Help, Quit"
  29. invalidInputMessage = "that is not a valid input"
  30.  
  31. #this function displays the title and game description upon startup
  32. def title():
  33. print("Ikea Quest")
  34. userName = input("Enter your name: ")
  35. print("\nYou have embarked on a great quest to the lands of Ikea to look "
  36. " for furniture explore the whole store to try and find it! \n"
  37. "Good luck", userName + "!")
  38. return userName
  39.  
  40. #this function handels changing the player's location and handeling score
  41. def changeAndScore(location, score, chooseQuit):
  42. global vistedParking, vistedDining, vistedBed, vistedLiving, vistedKitchen, vistedFood
  43. userInput = input("Enter in your next command: ").lower()
  44. #first if statement checks for what direction they enter
  45. #second if statement checks for what location they are then switches if needed
  46. #third if statements check if they have visted the location to see if you need to add score
  47. if userInput == "north":
  48. if location == parkingLot:
  49. location = diningArea
  50. if vistedDining == False:
  51. vistedDining = True
  52. score = score + 5
  53. elif location == diningArea:
  54. location = bedArea
  55. if vistedBed == False:
  56. vistedBed = True
  57. score = score + 5
  58. elif location == kitchenArea:
  59. location = foodArea
  60. if vistedFood == False:
  61. vistedFood = True
  62. score = score + 5
  63. else:
  64. print("You can't go " + userInput + ".")
  65.  
  66. elif userInput == "west":
  67. if location == kitchenArea:
  68. location = diningArea
  69. if vistedDining == False:
  70. vistedDining = True
  71. score = score + 5
  72. elif location == foodArea:
  73. location = bedArea
  74. if vistedBed == False:
  75. vistedBed = True
  76. score = score + 5
  77. elif location == bedArea:
  78. location = livingRoomArea
  79. if vistedLiving == False:
  80. vistedLiving = True
  81. score = score + 5
  82. else:
  83. print("You can't go " + userInput + ".")
  84.  
  85. elif userInput == "south":
  86. if location == bedArea:
  87. location = diningArea
  88. if vistedDining == False:
  89. vistedDining = True
  90. score = score + 5
  91. elif location == diningArea:
  92. location = parkingLot
  93. elif location == foodArea:
  94. location = kitchenArea
  95. if vistedKitchen == False:
  96. vistedKitchen = True
  97. score = score + 5
  98. else:
  99. print("You can't go " + userInput + ".")
  100.  
  101. elif userInput == "east":
  102. if location == diningArea:
  103. location = kitchenArea
  104. if vistedKitchen == False:
  105. vistedKitchen = True
  106. score = score + 5
  107. elif location == bedArea:
  108. location = foodArea
  109. if vistedFood == False:
  110. vistedFood = True
  111. score = score + 5
  112. elif location == livingRoomArea:
  113. location = bedArea
  114. if vistedBed == False:
  115. vistedBed = True
  116. score = score + 5
  117. else:
  118. print("You can't go " + userInput + ".")
  119.  
  120. elif userInput == "help":
  121. print(helpMessage)
  122. #if they enter quit makes this boolean true which will break out of the loop in main function
  123. elif userInput == "quit":
  124. chooseQuit = True
  125. else:
  126. print(invalidInputMessage)
  127.  
  128. return location, score, chooseQuit
  129.  
  130. #this function will display the ending to the player
  131. def ending(userName):
  132. print("\nCongratulations", userName, "you beat the game unfortunately your quest"
  133. " ends in a tragedy. You couldn't find what you were looking for. \n")
  134. print("COPYRIGHT 2017")
  135. print("This game was made by Nick Blaskey contact at nicholas.blaskey1@marist.edu \n")
  136.  
  137. #this function actually runs the game
  138. def main():
  139.  
  140. userName = title()
  141. #start the player off in the parking lot
  142. currentLocation = parkingLot
  143. #start score off at five because we start in a location and give 5 points for location
  144. score = 5
  145. #this boolean controls if the player decides to quit
  146. chooseQuit = False
  147.  
  148. #this loop runs the main game until the player wins or quits then it will break them out
  149. while True:
  150. print("\nYour current score is", score)
  151. print(currentLocation + "\n")
  152. currentLocation, score, chooseQuit = changeAndScore(currentLocation, score, chooseQuit)
  153.  
  154. #this if statement checks if the user has entered quit
  155. if chooseQuit == True:
  156. print(userName, "is a quitter!!! \n")
  157. break
  158. #this if statement checks if the user has enough poins to win if they do display the endng
  159. if score >= 30:
  160. ending(userName)
  161. break
  162.  
  163. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement