Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In order for a player to navigate your game, you will need to develop a function or functions using Python script . Your function or

In order for a player to navigate your game, you will need todevelop a function or functions using Python script. Your function or functions should do the following:

  • Show the player the different commands they can enter (such as "go North", "go West", and "get [item Name]").
  • Show the player's status by identifying the room they are currently in, showing a list of their inventory of items, and displaying the item in their current room.

You could make these separate functions or part of a single function, depending on how you prefer to organize your code.

  1. Next, begin developing a main function in your code. The main function will contain the overall gameplay functionality. Review the Project Two Sample Text Game Flowchart, located in the Supporting Materials section, to help you visualize how main() will work.
  2. For this step, simply add in a line of code to define your main function, and a line at the end of your code that will run main(). You will develop each of the pieces for main() in Steps #4-7.
  3. In main(),createa dictionary linking rooms to one another and linking items to their corresponding rooms. The game needs to store all of the possible moves per room and the item in each room in order to properly validate player commands (input). This will allow the player only to move between rooms that are linked or retrieve the correct item from a room. Use your storyboard and map from Project One to help you create dictionary.

The bulk of the main function should include aloop for the gameplay. In your gameplay loop,develop calls to the function(s) that show the player's status and possible commands. You developed these in Step #2. When called, the function(s) should display the player's current room and prompt the player for input (their next command). The player should enter a command to either move between rooms or to get an item, if one exists, from a room.

  1. Within thegameplay loop, you should includedecision branching to handle different commands and control the program flow. This should tell the game what to do for each of the possible commands (inputs) from the player. Use your pseudocode or flowcharts from Project One to help you with this code.
  • What should happen if the player enters a command to move between rooms?
  • What should happen if the player enters a valid command to get an item from the room?
  1. Be sure to also includeinput validationby developing code that tells the program what to do if the player enters an invalid command.
  2. Note: If you completed the Module Six milestone, you have already developed a portion of this code by handling "move" commands. Review any feedback from your instructor, copy your code into your "TextBasedGame.py" file, make any necessary adjustments, and finish developing the code.
  3. Thegameplay loop should continue looping, allowing the player to move to different rooms and acquire items until the player has either won or lost the game. Remember that the player wins the game by retrievingallof the items before encountering the room with the villain. The player loses the game by moving to the room with the villainbeforecollecting all of the items. Be sure to include output to the player for both possible scenarios: winning and losing the game.

This is a project I need to figure out. I have already have this code pasted below for moving room to room. And this is the storyboard.

IT 140Saving an Incan Empire

Conquistador Francisco Pizzaro has taken over an ancient and sacred Incan Temple. It serves as a protection for the entire empire of Incas who believe their sun god, Capac Raymi will protect them from the Spanish conquest.You need to defeat Pizzaro before he allows his army into the temple.Obtaining the tunic from the weaving room will give you protection for you body, you need the mask from the war room to add to the fierceness of your defense, the llama figure from the priest's room which serves as a talisman for luck, a quipu from the food storage to use as a map throughout the temple, the gold bracelet from the priestess's room to bribe Pizzaro,the truncheon from the gold room for defense and the gold medallion from the Capac Raymi Sun God's room to keep away from Pizzaro from learning the secrets of the priests.Here is a map of the temple's rooms and items to navigate your quest:

#starting room rooms = { 'War Room': {'West':'Food Storage'}, 'Food Storage': {'East': 'War Room', 'West': 'Gold Room'}, 'Gold Room': {'East': 'Food Storage', 'North': "Capac Raymi Sun God's room"}, "Capac Raymi Sun God's room": {'East': "Priestess's Room", 'South': 'Gold Room'}, "Priestess's Room": {'West': "Capac Raymi Sun God's room", 'North': 'Weaving Room'}, 'Weaving Room': {'South': "Priestess's Room", 'East': "Priests' Room"}, "Priests' Room": {'West': 'Weaving Room', 'South': 'Tomb Room'}, 'Tomb Room': {'North': "Priests' Room"}}items = { 'War Room': 'Gold & Turqoise Mask', 'Food Storage': 'Quipo', 'Gold Room': 'Truncheon', "Capac Raymi Sun God's room": 'Gold Medallion', "Priestess's Room": 'Gold Bracelet', 'Weaving Room': 'Tunic', "Priests' Room": 'Llama Figurine',}#loop for room travel current_room = "Capac Raymi Sun God's room" inventory = []#Sample function showing the goal of the game and move commands def show_instructions(): #print the instructions for the user  print('Saving an Incan Empire Game') print("Collect 7 items to defeat Pizzaro") print("Move commands: South, North, East, West") print("Add to Inventory: get 'item name'") show_instructions()while (True): # loop print(' -----------------------------------------------------') print('Currently you are in ',current_room) # printing state # dispplay inventory print('Current inventory: ', inventory) # this will ask the user to enter command 'add item_name' # to break the loop the user can enter just add while True: # ask to collect item in current room if current_room in items.keys() and items[current_room] != None: print('This room has ', items[current_room]) command = input('Add item?: ') item = command.split()[1:] command = command.split()[0] command = command.lower() if command == 'add': item = ' '.join(item).lower() item = item.rstrip() if item == items[current_room].lower(): print('Adding ' + items[current_room] + ' to inventory . . .') inventory.append(items[current_room]) items[current_room] = None else: if len(item) > 0: print('this item is not present in this room') break else: print('Invalid command') else: break # ask for next direction direction = input('Enter direction to go (North/East/West/South): ') # asking user for input direction = direction.capitalize() # making first character capital remaining lower # update room state if (direction == 'Exit'): # if print('Thanks for playing the game, exitting . . . ') exit(0) # exit function if (direction == 'East' or direction == 'West' or direction == 'North' or direction == 'South'): # if if direction not in rooms[current_room].keys(): print('The room your in does not have a pathway in that direction, try a different direction!') # print else: current_room = rooms[current_room][direction] else: print('Invalid Command!') # print # if we have reached a room then we either win or loose the game if current_room == 'Tomb Room': if len(inventory) == 7: print('Congratulations you have defeated Pizzaro!!') else: print("Game Over") print('try again') break

image text in transcribed
East Weaving Priests' Room Room West Item: Tunic Item: Llama Figurine North South North South Capac East Priestess's Tomb Room Raymi Sun Room God's room Pizarro! West Item: Gold Item: Gold Medallion Bracelet South East Food East War Room Gold Room: Storage Item: Gold Item: Item: Quipu & Turquoise Truncheon West Mask West

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transport Operations

Authors: Allen Stuart

2nd Edition

978-0470115398, 0470115394

Students also viewed these Programming questions

Question

Explain the difference between a cash CDO and a synthetic CDO.

Answered: 1 week ago

Question

What does a decision-making unit comprise?

Answered: 1 week ago