IMPORTANT: The directions include sample code from the dragon-themed game. Be sure to modify any sample code so that it fits the theme of your game. First, create a new file in the PyCharm integrated development environment (IDE), title it “TextBasedGame.py,” and include a comment at the top with your full name. As you develop your code, remember that you must use industry standard best practices including in-line comments and appropriate naming conventions to enhance the readability and maintainability of the code. In order for a player to navigate your game, you will need to develop 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. #Sample function showing the goal of the game and move commands def show_instructions(): #print a main menu and the commands print("Dragon Text Adventure Game") print("Collect 6 items to win the game, or be eaten by the dragon.") print("Move commands: go South, go North, go East, go West") print("Add to Inventory: get 'item name'") #In this solution, the player’s status would be shown in a separate function. #You may organize your functions differently. 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. 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. In main(), create a 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 your dictionary. Here is an example of a dictionary for a few of the rooms from the sample dragon text game.#A dictionary linking a room to other rooms #and linking one item for each room except the Start room (Great Hall) and the room containing the villain rooms = { 'Great Hall' : { 'South' : 'Bedroom', 'North': 'Dungeon', 'East' : 'Kitchen', 'West' : 'Library' }, 'Bedroom' : { 'North' : 'Great Hall', 'East' : 'Cellar', 'item' : 'Armor' }, 'Cellar' : { 'West' : 'Bedroom', 'item' : 'Helmet' }, 'Dining Room' : { 'South' : 'Kitchen', 'item' : 'Dragon' } #villain } #The same pattern would be used for the remaining rooms on the map. The bulk of the main function should include a loop 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. Here is a sample status from the dragon text game: You are in the Dungeon Inventory: [] You see a Sword ---------------------- Enter your move: As the player collects items and moves between rooms, the status function should update accordingly. Here is another example after a player has collected items from two different rooms: You are in the Gallery Inventory: [‘Sword’, ‘Shield’] -------------- Enter your move: The gameplay 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 retrieving all of the items before encountering the room with the villain. The player loses the game by moving to the room with the villain before collecting all of the items. Be sure to include output to the player for both possible scenarios: winning and losing the game. Hint: What is the number of items the player needs to collect? How could you use this number to signal to the game that the player has won? Here is a sample from the dragon text game of the output that will result if the player wins the game: Congratulations! You have collected all items and defeated the dragon! Thanks for playing the game. Hope you enjoyed it. If the player loses the game, they will see the following output: NOM NOM...GAME OVER! Thanks for playing the game. Hope you enjoyed it.

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter11: More Object-oriented Programming Concepts
Section: Chapter Questions
Problem 8PE
icon
Related questions
Question

IMPORTANT: The directions include sample code from the dragon-themed game. Be sure to modify any sample code so that it fits the theme of your game.

  1. First, create a new file in the PyCharm integrated development environment (IDE), title it “TextBasedGame.py,” and include a comment at the top with your full name. As you develop your code, remember that you must use industry standard best practices including in-line comments and appropriate naming conventions to enhance the readability and maintainability of the code.
  2. In order for a player to navigate your game, you will need to develop 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.
    #Sample function showing the goal of the game and move commands def show_instructions(): #print a main menu and the commands print("Dragon Text Adventure Game") print("Collect 6 items to win the game, or be eaten by the dragon.") print("Move commands: go South, go North, go East, go West") print("Add to Inventory: get 'item name'") #In this solution, the player’s status would be shown in a separate function. #You may organize your functions differently.
  3. 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.

    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.

  4. In main(), create a 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 your dictionary.
    Here is an example of a dictionary for a few of the rooms from the sample dragon text game.#A dictionary linking a room to other rooms #and linking one item for each room except the Start room (Great Hall) and the room containing the villain rooms = { 'Great Hall' : { 'South' : 'Bedroom', 'North': 'Dungeon', 'East' : 'Kitchen', 'West' : 'Library' }, 'Bedroom' : { 'North' : 'Great Hall', 'East' : 'Cellar', 'item' : 'Armor' }, 'Cellar' : { 'West' : 'Bedroom', 'item' : 'Helmet' }, 'Dining Room' : { 'South' : 'Kitchen', 'item' : 'Dragon' } #villain } #The same pattern would be used for the remaining rooms on the map.
  5. The bulk of the main function should include a loop 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.
    Here is a sample status from the dragon text game:
    You are in the Dungeon Inventory: [] You see a Sword ---------------------- Enter your move: As the player collects items and moves between rooms, the status function should update accordingly. Here is another example after a player has collected items from two different rooms: You are in the Gallery Inventory: [‘Sword’, ‘Shield’] -------------- Enter your move:


  6. The gameplay 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 retrieving all of the items before encountering the room with the villain. The player loses the game by moving to the room with the villain before collecting all of the items. Be sure to include output to the player for both possible scenarios: winning and losing the game.

    Hint: What is the number of items the player needs to collect? How could you use this number to signal to the game that the player has won?
    Here is a sample from the dragon text game of the output that will result if the player wins the game: Congratulations! You have collected all items and defeated the dragon! Thanks for playing the game. Hope you enjoyed it. If the player loses the game, they will see the following output: NOM NOM...GAME OVER! Thanks for playing the game. Hope you enjoyed it.
Library
Item: Book
East
West
Dungeon
Item: Sword
North
North
Great Hall
Bedroom
Item: Armor
South
South
East
West
East
West
East
West
North
Gallery
Item: Shield
Dining Room
Dragon!
Kitchen
Item: Sword
Cellar
South
Item: Helmet
Transcribed Image Text:Library Item: Book East West Dungeon Item: Sword North North Great Hall Bedroom Item: Armor South South East West East West East West North Gallery Item: Shield Dining Room Dragon! Kitchen Item: Sword Cellar South Item: Helmet
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Running Time of Application
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT