hello i m new to the python and i m making a mud game i got stuck at a certain point where i need to make a code in which user can put a direction and game responds with saying can he go or not and also with inventory in which pick/drop items can be done i have tried to code in python help me with it. there are 3 level in which player has to go every level to complete the game.
# steps to connect every level to other level.
level = {
'level 1': {'North': 'level 2 door', 'East': 'dead end', 'West': 'dead end',"items":["Sword","Door key","coins"]},
'level 2': {'South': 'level 1', 'East': 'dead end', 'West': 'secret mission','North': 'level 3 door' ,"items":["energy portion","Door key","coins"] },
'secret mission': {'North': 'level 3 door', 'East': 'dead end', "items":["Bow&Arrow","Door key","coins"]},
'level 3': {'South': 'level 2 door','North': 'door in which princess is kept',"items":["extra armor"]},
}
directions = ['go North', 'go South', 'go East', 'go West']
pick_up_items = ['coins', 'door key', 'get Armor', 'get Sword', 'get bow&arrow', 'get energy portion']
print(instructions)
current_level = 'level1'
item_in_level = 'sword, door key, coins'
inventory = ['sword, door key, coins']
while True:
if inventory == ['coins', 'door key', 'Armor', 'Sword', 'bow&arrow', 'energy portion']:
print('Congratulations! You collected all the items, now you can go into'
'level 3 and defeat the Dr.devil!')
elif current_room == 'level 3':
print('A bolt of lightning and thunder streaks towards you and your vision goes black..... Game Over!')
break
# displays the players current location
print('You are in the {}.'.format(current_level))
print('Inventory:', inventory)
if item_in_level: #checks to see if there is an item in the room
print('You see a'.format(item_in_level))
else:
print("You don't see anything useful")
# gets the users input
command = input('\nWhat do you wish to do? ') # this controls the movement
if command in directions:
command = command.split()[1]
if command in level[current_level].keys():
current_level = level[current_level][command]
item_in_level =level[current_level]["item"]
else:
# if the player inputs a bad movement
print('please write correct direction!')
# Checks to see if the player types a 'get' command and adds the item in the room to the players inventory.
if command in pick_up_items:
command = command.split()[1]
if command in level[current_level].keys():
inventory.append(current_room['item'])
else:
# if the player inputs a item not in the room
print('this item is not available here!')