Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Introduction to Programming
- # Nicholas Blaskey
- # 9/27/2017
- parkingLot = "You are in a parking lot of ikea. North of you is the entrance."
- diningArea = ("You are in a dining room section of ikea. To your north is the"
- " bedroom area and east is the kitchen Area")
- bedArea = ("You are in the bed room section of ikea. To your west is the"
- " living room area and to your east is the subway food chain"
- " and to your south is the dining area")
- livingRoomArea = ("You are in the living room section of ikea. To your"
- " east is the bedroom area")
- kitchenArea = ("You are in the kitchen area of ikea. To your north is"
- " the subway food chain and west of you is the dining "
- " room section")
- foodArea = ("You are at a subway located inside of ikea. To your west"
- " is the bedroom section of ikea and south is the kitchen area.")
- #vistedParking starts off true because we start the user in the parking lot
- vistedParking, vistedDining, vistedBed = True, False, False
- vistedLiving, vistedKitchen, vistedFood = False, False, False
- helpMessage = "Valid commands are North, West, East, South, Help, Quit"
- invalidInputMessage = "that is not a valid input"
- #this function displays the title and game description upon startup
- def title():
- print("Ikea Quest")
- userName = input("Enter your name: ")
- print("\nYou have embarked on a great quest to the lands of Ikea to look "
- " for furniture explore the whole store to try and find it! \n"
- "Good luck", userName + "!")
- return userName
- #this function handels changing the player's location and handeling score
- def changeAndScore(location, score, chooseQuit):
- global vistedParking, vistedDining, vistedBed, vistedLiving, vistedKitchen, vistedFood
- userInput = input("Enter in your next command: ").lower()
- #first if statement checks for what direction they enter
- #second if statement checks for what location they are then switches if needed
- #third if statements check if they have visted the location to see if you need to add score
- if userInput == "north":
- if location == parkingLot:
- location = diningArea
- if vistedDining == False:
- vistedDining = True
- score = score + 5
- elif location == diningArea:
- location = bedArea
- if vistedBed == False:
- vistedBed = True
- score = score + 5
- elif location == kitchenArea:
- location = foodArea
- if vistedFood == False:
- vistedFood = True
- score = score + 5
- else:
- print("You can't go " + userInput + ".")
- elif userInput == "west":
- if location == kitchenArea:
- location = diningArea
- if vistedDining == False:
- vistedDining = True
- score = score + 5
- elif location == foodArea:
- location = bedArea
- if vistedBed == False:
- vistedBed = True
- score = score + 5
- elif location == bedArea:
- location = livingRoomArea
- if vistedLiving == False:
- vistedLiving = True
- score = score + 5
- else:
- print("You can't go " + userInput + ".")
- elif userInput == "south":
- if location == bedArea:
- location = diningArea
- if vistedDining == False:
- vistedDining = True
- score = score + 5
- elif location == diningArea:
- location = parkingLot
- elif location == foodArea:
- location = kitchenArea
- if vistedKitchen == False:
- vistedKitchen = True
- score = score + 5
- else:
- print("You can't go " + userInput + ".")
- elif userInput == "east":
- if location == diningArea:
- location = kitchenArea
- if vistedKitchen == False:
- vistedKitchen = True
- score = score + 5
- elif location == bedArea:
- location = foodArea
- if vistedFood == False:
- vistedFood = True
- score = score + 5
- elif location == livingRoomArea:
- location = bedArea
- if vistedBed == False:
- vistedBed = True
- score = score + 5
- else:
- print("You can't go " + userInput + ".")
- elif userInput == "help":
- print(helpMessage)
- #if they enter quit makes this boolean true which will break out of the loop in main function
- elif userInput == "quit":
- chooseQuit = True
- else:
- print(invalidInputMessage)
- return location, score, chooseQuit
- #this function will display the ending to the player
- def ending(userName):
- print("\nCongratulations", userName, "you beat the game unfortunately your quest"
- " ends in a tragedy. You couldn't find what you were looking for. \n")
- print("COPYRIGHT 2017")
- print("This game was made by Nick Blaskey contact at nicholas.blaskey1@marist.edu \n")
- #this function actually runs the game
- def main():
- userName = title()
- #start the player off in the parking lot
- currentLocation = parkingLot
- #start score off at five because we start in a location and give 5 points for location
- score = 5
- #this boolean controls if the player decides to quit
- chooseQuit = False
- #this loop runs the main game until the player wins or quits then it will break them out
- while True:
- print("\nYour current score is", score)
- print(currentLocation + "\n")
- currentLocation, score, chooseQuit = changeAndScore(currentLocation, score, chooseQuit)
- #this if statement checks if the user has entered quit
- if chooseQuit == True:
- print(userName, "is a quitter!!! \n")
- break
- #this if statement checks if the user has enough poins to win if they do display the endng
- if score >= 30:
- ending(userName)
- break
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement