Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You work for a small company that creates text - based games. You recently pitched your design ideas for a text - based adventure game

You work for a small company that creates text-based games. You recently pitched your design ideas for a text-based adventure game to your team. Your team was impressed by all of your designs, and would like you to develop the game! You will be able to use the map and the pseudocode or flowcharts from your designs to help you develop the code for the game. In your code, you have been asked to include clear naming conventions for functions, variables, and so on, along with in-line comments. Not only will these help you keep track as you develop, but they will help your team read and understand your code. This will make it easier to adapt for other games in the future.
Recall that the game requires players to type in a command line prompt to move through the different rooms and get items from each room. The goal of the game is for the player to get all of the items before encountering the room that contains the villain. Each step of the game will require a text output to let the player know where they are in the game, and an option of whether or not to obtain the item in each room.
My code so far:
def show_instructions():
# print a main menu and the commands
print("Commands:")
print("Go North")
print("Go East")
print("Go West")
print("Go South")
print("Exit")
print("Get [Item]")
def player_status(location, inventory):
# print player current room and inventory
print('You are in the '+ location)
# print you see available items
if location != 'Containment Building':
item = rooms[location]['item']
if item not in inventory:
print('You see a'+ item)
# print inventory
print('Inventory:', inventory)
# Inventory list to store items
inventory =[]
rooms ={
'Containment Building': {'South': 'Condenser Room', 'North': 'Electrical Room', 'East': 'Cooling Tower',
'West': 'Pump Room'}, # Start Room
'Condenser Room': {'North': 'Containment Building', 'East': 'Control Room', 'item': 'Southbridge'},
'Control Room': {'West': 'Condenser Room', 'item': 'Zombie'}, # Villain Room
'Pump Room': {'East': 'Containment Building', 'item': 'Super I/O Chip'},
'Electrical Room': {'South': 'Containment Building', 'East': 'Generator Room', 'item': 'RAM Module'},
'Generator Room': {'West': 'Electrical Room', 'item': 'Floppy Disk'},
'Transformer Room': {'South': 'Cooling Tower', 'item': 'RMOS Battery'},
'Cooling Tower': {'North': 'Transformer Room', 'item': 'Backup Battery'}
}
# Start room
location = 'Containment Building'
show_instructions()
while True:
#
player_status(location, inventory)
command = input("")
if location != 'Containment Building':
item = rooms[location]['item']
else:
item = 'Nothing'
if command in rooms[location]:
location = rooms[location][command]

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

Students also viewed these Databases questions

Question

5. Identify three characteristics of the dialectical approach.

Answered: 1 week ago

Question

6. Explain the strengths of a dialectical approach.

Answered: 1 week ago

Question

4. Explain the strengths and weaknesses of each approach.

Answered: 1 week ago