Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# Sandra Duffany # Function to display instructions def game _ instructions ( ) : # display Intro Instructions print ( ' Congrats you found

# Sandra Duffany
# Function to display instructions
def game_instructions():
# display Intro Instructions
print('Congrats you found a clue!')
print('Collect all six clues to be able to catch, and arrest the robber!')
print('Move Commands: North, East, South, and West',
print('Add to bag: Pick up "item Name"'),
print('Quit Game: EXIT'),
Game_instructions ())
#define rooms and items
rooms ={
'Living Room': {'North': 'Bedroom', 'South':'Entryway/Office'},
'Kitchen': {'East':'Living room''item''Flour HandPrints'},
'Bedroom':{'South': 'Living room','East':'Bathroom'},
'Bathroom':{'West':'Bedroom', "item":'Dropped glove'},
'Storeroom':{'South':'Master Bedroom', "item":'Muddy Footprints'},
'Master bedroom': {'North':'Storeroom','West':'Living room',"item": 'Cellphone'},
'Entryway/office': {'North':'Living room','East':'Gaming room',"item": 'Ripped T-Shirt Piece'},
'Gaming room': {'West':'Entryway/Office'}
}
#Set player in beginning of the crime scene home, and give them an empty inventory
current_room= 'Living Room'
inventory=[]
#function to get the new room based off of the current room and the players direction
def get_new_room(current_room):
new_room = current_room
for i in rooms:
if i == current_room
return new_room
#function to get the item in the current room
def get_item(current_room)
if 'item' in rooms[current_room]:
return rooms[current_room]['item']
if 'item' not in rooms[current_room]:
return 'This room has no item!'
# Main game loop
while current_room:
#Display current room and the things in inventory
print('You are in the [current room]')
print('Inventory:', Inventory)
# Get the items in the current room
item= get_item(current_room)
if item:'Muddy footprints'
if current_room== 'Living room'
print('There is nothing to collect in this room')
if current_room=('Bedroom')
if item in inventory:
print('you have collected this clue!')
else:
print('You have already collected this clue')
pickup= input()
pickup= pickup.title()
if pickup== str('Get'+ item):
inventory.append(item)
print('You picked up'+ item)
if pickup == 'EXIT':
print('Goodbye, thank you for playing!')
break
if item == 'Robber':
if len(inventory)==6:
print('Success! You collected all the clues to catch and arrest the robber!')
break
if len(inventory)!=6:
print('you have not collected enough clues to arrest the robber, he now gets to walk free')
break
#Get player input for next direction
direction = input('Enter the direction you would like to go')
direction = direction.capitalize()
if direction == 'EXIT':
print('Goodbye!')
break
if direction== 'North' or direction == 'South' or direction == 'East' or direction == 'West':
#Get new room based on the direction
new_room= get_new_room(current_room,direction)
if new_room == current_room:
print('You cannot go that way')
else:
current_room = new_room
else:
print('you cannot go that way')
Can someone help make this code work on pycharm?

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_2

Step: 3

blur-text-image_3

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

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago