Answered step by step
Verified Expert Solution
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 textbased games. You recently pitched your design ideas for a textbased 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 inline 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 showinstructions:
# print a main menu and the commands
printCommands:
printGo North"
printGo East"
printGo West"
printGo South"
printExit
printGet Item
def playerstatuslocation inventory:
# print player current room and inventory
printYou are in the location
# print you see available items
if location 'Containment Building':
item roomslocationitem
if item not in inventory:
printYou see a item
# print inventory
printInventory: 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 IO 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'
showinstructions
while True:
#
playerstatuslocation inventory
command input
if location 'Containment Building':
item roomslocationitem
else:
item 'Nothing'
if command in roomslocation:
location roomslocationcommand
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started