Question: I am doing a text based game in python. I have done the movement but am having a hard time with the 'get' for items

I am doing a text based game in python. I have done the movement but am having a hard time with the 'get' for items located in those rooms. I can make a sperate items dictionary or add it to the rooms. Either way when the pick up it up and add to the inventory, the item needs to be deleted from the dictionary. Here is the code i have so far:
# Rooms dictionary
rooms ={
'Barracks': {'North': 'Officer Quarters', 'East': 'Courtyard', 'South': 'Stables', 'West': 'Arsenal'},
'Arsenal': {'East': 'Barracks', 'South': 'Armory'},
'Armory': {'North': 'Arsenal'},
'Stables': {'North': 'Barracks', 'South': 'Kitchen'},
'Kitchen': {'North': 'Stables', 'East': 'Great Hall'},
'Officer Quarters': {'East': 'Lookout Tower', 'South': 'Barracks'},
'Lookout Tower': {'East': 'Main Gate', 'South': 'Courtyard', 'West': 'Officer Quarters'},
'Main Gate': {'West': 'Lookout Tower'},
'Courtyard': {'North': 'Lookout Tower', 'South': 'Great Hall', 'West': 'Barracks'},
'Great Hall': {'North': 'Courtyard', 'West': 'Kitchen'}
}
#List commands
movement_list =['Move North', 'Move South', 'Move East', 'Move West']
print(f"Please use the following commands to move: {movement_list}")
#Players starting point
player_room = 'Barracks'
#Movement loop
while player_room != exit:
print(f"You currently stand in the {player_room}.")
#get player coomand
move = input("Make your next move. Beware The Goblin King! (North, South, East, West or type exit to exit the game or move command for the move commands list: ").strip().lower()
#Commands
if move == 'exit':
player_room = exit
elif move == 'move command':
print(f"Please use the following command to move: {movement_list}") #list move commands if forgotten
elif move in ['move north', 'move south', 'move east', 'move west']:
direction = move.split()[1].capitalize() #extracts and capitalizes direction for rooms dict
if direction in rooms[player_room]:
player_room = rooms[player_room][direction]
print(f"You swiftly and silently move {direction} to {player_room}.") #moves you to a room
else:
print(f"You bang your head on the wall.You can't go {direction} from the {player_room}.") #bangs head if you can't go that way
else:
print("Invalid command. Please enter a valid command.") #invalid command if anything else typed beside commands
print("Thank you for moving around my fort!") #goodbye

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 Programming Questions!