Question: def show _ instruction ( ) : print ( ' Welcome Player' ) print ( ' You woke up in a hospital alone. You need

def show_instruction():
print('Welcome Player')
print('You woke up in a hospital alone. You need to find 9 items in the nine rooms.')
print('There is a mutant zombie in one the rooms ,so be weary.')
print('Move commands: North, East, South, West')
print('Add to Inventory: Get Items')
print('-------------------------------------------------------------------------------')
def show_status():
print(f'You are in the {current_room}')
print(f'Inventory: {inventory}')
print('You look around and see', rooms[current_room]['item'])
rooms ={
'Bathroom': {'East': 'Room Six', 'item': 'Shoes'},
'Room Six': {'West': 'Bathroom', 'South': 'Hallway', 'item': 'Clothes'},
'Hallway': {'North': 'Room Six', 'East': 'Backdoor Room ', 'South': 'Staircase', ' West': ' Front Room', 'item': 'Gun'},
'Front Room': {'East': ' Hallway', 'item': 'Backpack'},
'Backdoor Room': {'West': 'Hallway', 'North': 'Morgue Room', 'item': 'Parking Lot key'},
'Morgue Room': {'South': ' Backdoor Room', 'item': 'Car Key'},
'Staircase': {'North': 'Hallway', 'East': 'Basement', 'item': 'Extra bullets'},
'Basement': {'West': 'Staircase', 'East': 'Parking Lot', 'item': 'Canned food and water'},
'Parking Lot': {'West': 'Basement', 'item': 'Mutant Zombie'}
}
def get_new_state(direction_from_user, current_room ):
new_location = current_room
if direction_from_user in rooms[current_room]:
new_location = rooms[current_room][direction_from_user]
else:
print('You hit the wall. Try again')
return new_location
show_instruction()
current_room = 'Room Six'
inventory =[]
while True:
show_status()
direction_from_user = input('Enter a command' '>>').title()
if direction_from_user in ('North', 'East', 'South', 'West'):
new_location = get_new_state(direction_from_user,current_room)
current_room = new_location
elif direction_from_user ==(' Get '+ rooms[current_room]['item']):
if rooms[current_room]['item'] not in inventory:
inventory.append(rooms[current_room]['item'])
print('You picked up {} and put in your inventory'.format(rooms[current_room]['item']))
else:
print('-----------Item already picked up ---------')
elif current_room == 'Parking Lot':
print('CONGRATULATION !!! You successfully got the items, beat the Mutant Zombie, and got out of the hospital')
break
else:
print('Invalid')

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!