For this milestone, we will be submitting a working draft of the code for a simplified version
Fantastic news! We've Found the answer you've been seeking!
Question:
For this milestone, we will be submitting a working draft of the code for a simplified version of the text-based game that we are developing for Project Two. We will focus on displaying how a room dictionary works with the "move" commands. This will include the if, else, and elif statements that move the adventurer from one room to another.
- Before beginning this milestone, it is important to understand the required functionality for this simplified version of the game. The game should prompt the player to enter commands to either move between rooms or exit the game.
- In PyCharm, we will create a new code file titled "ModuleSixMilestone.py." As we develop we code, we must use industry-standard best practices, including in-line comments and appropriate naming conventions, to enhance the readability and maintainability of the code.
- Next, copy the following dictionary into a PY file. This dictionary links rooms to one another and will be used to store all possible moves per room, in order to properly validate player commands (input). This will allow the player to move only between rooms that are linked.
- Next, we will develop code to meet the required functionality, by prompting the player to enter commands to move between the rooms or exit the game. To achieve this, we must develop the following:
- A gameplay loop that includes:
- Output that displays the room the player is currently in
- Decision branching that tells the game how to handle the different commands. The commands can be to either move between rooms (such as go North, South, East, or West) or exit.
- If the player enters a valid "move" command, the game should use the dictionary to move them into the new room.
- If the player enters "exit," the game should set their room to a room called "exit."
- If the player enters an invalid command, the game should output an error message to the player (input validation).
- A way to end the gameplay loop once the player is in the "exit" room
- A gameplay loop that includes:
- As we develop, we should debug our code to minimize errors and enhance functionality. After we have developed all of our code, be sure to run the code to test and make sure it is working correctly.
- What happens if the player enters a valid direction? Does the game move them to the correct room?
- What happens if the player enters an invalid direction? Does the game provide the correct output?
- Can the player exit the game?
#A dictionary for the simplified dragon text game #The dictionary links a room to other rooms. rooms = { 'Great Hall': {'South': 'Bedroom'}, 'Bedroom': {'North': 'Great Hall', 'East': 'Cellar'}, 'Cellar': {'West': 'Bedroom'} }
Related Book For
Posted Date: