So I have been working on this text based game in python for a project and I have gotten it where I can move around but can not get it where it will pick up the item itself. any help would be greatly appreciated. I am no expert as I am current going to school for programming and still learning.
def game_instructions(): # print a main menu and the commands
print("Killer Clown Text Adventure Game")
print("You must collect all six items to win the game or be killed by the Killer Clown!!")
print("Move commands: go South, go North, go East, go West, Exit")
print("Add to Inventory: get 'item name'")
rooms = {
'Front Gates': {'South': 'Games Area', 'East': 'Ticket Booth', 'item': 'none'},
'Games Area': {'North': 'Front Gates', 'East': 'Prize Area', 'West': 'Food Court', 'South': 'Storage Shed',
'item': 'Big Mallet'},
"Food Court": {'East': 'Games Area', 'item': 'pie'},
'Prize Area': {'West': 'Games Area', 'North': 'Fun House', 'item': 'Net'},
'Fun House': {'South': 'Prize Area', 'item': 'none'},
'Storage Shed': {'North': 'Games Area', 'East': 'Parking Lot', 'item': 'Flash Light'},
'Ticket Booth': {'West': 'Front Gates', 'item': 'Clown-B-Gone Book'},
'Parking Lot': {'West': 'Storage Shed', 'item': 'Keys'}
}
def room_movement(current_room, move, rooms):
current_room = rooms[current_room][move]
return current_room
def user_info():
print('You are in the {}'.format(current_room))
print('Inventory: ', inventory)
print('*' * 25)
def get_item(current_room):
if 'item' in rooms[current_room]: # if statement
return rooms[current_room]['item'] # return statement
else:
return 'This room has no item!' # return statement
game_instructions()
input('Press Enter to Continue')
inventory = []
current_room = 'Front Gates'
move = ''
while current_room != 'Fun House':
user_info()
move = input('Enter your next move.\n').title().split()
item = get_item(current_room)
print('There seems to be an item nearby')
if move == 'take':
move = input('What do you want to take? ').title().split()
if move in rooms[current_room]['item']:
inventory.append(item)
else:
print(f"There's no {item} here.")
if len(move) >= 2 and move[0].lower() == 'go' and move[1].capitalize() in rooms[current_room].keys():
current_room = room_movement(current_room, move[1].capitalize(), rooms)
continue
elif len(move) == 1 and move[0].lower() == 'exit':
current_room = 'exit'
else:
print('Invalid command')