from game_data import World, Item, Location from player import Player if __name__ == "__main__": WORLD = World("map.txt", "locations.txt", "items.txt") PLAYER = Player( 2, 2 ) # set starting location of player; you may change the x, y coordinates here as appropriate menu = ["look", "inventory", "score", "quit", "back"] while not PLAYER.victory: location = WORLD.get_location(PLAYER.x, PLAYER.y) # ENTER CODE HERE TO PRINT LOCATION DESCRIPTION # depending on whether or not it's been visited before, # print either full description (first time visit) or brief description (every subsequent visit) print("What to do? \n") print("[menu]") for action in location.available_actions(): print(action) choice = input("\nEnter action: ") if (choice == "[menu]"): print("Menu Options: \n") for option in menu: print(option) choice = input("\nChoose action: ") # CALL A FUNCTION HERE TO HANDLE WHAT HAPPENS UPON USER'S CHOICE # REMEMBER: the location = w.get_location(p.x, p.y) at the top of this loop will update the location if the
import os from game_data import World, Item, Location from player import Player if __name__ == "__main__": WORLD = World() PLAYER = Player(0, 0) menu = ["look", "inventory", "score", "quit"] quit = False while not PLAYER.victory and PLAYER.moves_remaining > 0 and quit == False: location = WORLD.get_location(PLAYER.x, PLAYER.y) if location.is_new(): print(location.get_full_description()) PLAYER.score += location.points else: print(location.get_brief_description()) location.visit() print('You have ' + str(PLAYER.moves_remaining) + ' moves remaining.') print("What shall you do? \n") print("Menu") for action in WORLD.get_available_actions(location, PLAYER.get_inventory()): print(action) choice = '' while (choice not in WORLD.get_available_actions( location, PLAYER.get_inventory()) and quit == False):