I can't figure out what is wrong with my code it won't output directions, prompts for direction or get items and I need an exit as well but nothing is working can you please help me find a solution....


I can't figure out what is wrong with my code it won't output directions, prompts for direction or get items and I need an exit as well but nothing is working can you please help me find a solution.




def show_instructions():
# print main menu and how to move
print('Escape to Another Galaxy Text Game')
print('Collect 6 items to escape and win the game, or be annihilated by the evil alien Goobert')
print('Move Command:go south, go north, go east, go west, Exit')
print('get Alien Blaster. get Spare Parts. get fuel.')
print('get space snacks. get map.')




def show_status(current_room, inventory, room, rooms):
print('---------------------') # make another line after each move
print('You are in the' + current_room) # print players current location


print('inventory:' + str(inventory)) # print player current inventory
if "Item" in rooms[current_room]: # print an item if there is one
print("I can get the" + rooms[current_room]["Item"])


def main():


Inventory = [] # define inventory empty
# a dictionary linking rooms together
rooms = {
'Central Station': {'south': 'Parts and Service', 'north': 'Navigation Room', 'east': 'Cafeteria',
'west': 'Milky Way'},
'Parts and Service': {'north': 'Central Station', 'east': 'Experiment', 'Item': 'Alien Blaster'},
'Experiment': {'west': 'Parts and Service', 'Item': 'Spare Parts'},
'Navigation Room': {'south': 'Central Station', 'east': 'Control Room', 'Item': 'Goobert'},
'Control Room': {'west': 'Navigation', 'Item': 'Fuel'},
'Cafeteria': {'west': 'Central Station', 'north': 'Orbit Room', 'Item': 'Net'},
'Orbit Room': {'south': 'Cafeteria', 'Item': 'Space Snacks'},
'Milky Way': {'east': 'Central Station', 'Item': 'Map'}
}


current_room = "Central Station"


show_instructions()


while True:
show_status(current_room, Inventory, rooms)
if "Item" in rooms[current_room]:
if rooms[current_room]["Item"] == "Goobert": #Player will be annihilated and the game will end
print("You have been annihilated......Game over!")
print("Come back and play again!")
break


if len(Inventory) == 6:
print("You have collected all items and are able to escape!!!")
print("You have won the game!!!")
break
print("Enter which way to move:") # Player is prompted which direction to move


move = ""
while move == "":
move = input()
move = move.split()
if len(move) != 2:
print("Invalid move, try another direction.")
continue
elif move[0] == "go":
continue
if move[1] in rooms[current_room]:
current_room = rooms[current_room][move[1]] # main of program


else:
print("Wrong way, try again!")
elif move[0] == "get":
if "Item" in rooms[current_room] and move[1] in rooms[current_room]["Item"]:
Inventory += [move[1]]
print(move[1] + "!")
else:
print("Can't get" + move[1] + "!")
else:
print("Invalid move")


if __name__ == '__main__':
main()



Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here