def market(): entities.player.location = entities.getLocation('Market') print(''' +-----------------------------------------------------+ | Welcome to the Market! | | Type an item\'s name to purchase it. | | Type "info <item>" for more information on an item. | | Type "exit" to leave the store. | +-----------------------------------------------------+''') isVendor = False while not isVendor: vendors = [] for vendor in entities.vendors: vendors.append(vendor.name) command = utils.choose('\nPlease type the vendor you want to visit.', vendors) for vendor in entities.vendors: if vendor.name == command: vendorToVisit = vendor isVendor = True break if command == 'exit': print('You left the store.') return else: print('Vendor or command not found.') break utils.goToVendor(vendorToVisit)
def loadGame(name=None): global usr, usrFile, previousVendor users = [] for file in os.listdir(utils.fileDir + '/saves'): if file.endswith('.save') or file.endswith('.db'): users.append(file.split('.')[0]) try: usr = utils.choose('List of users:', users, 'What is your username?') usrFile = usr + '.save' except KeyboardInterrupt: play() try: entities.worldEntities = utils.loadInfo(usr, 'worldEntities') entities.player = utils.loadInfo(usr, 'player.' + usr) previousVendor = utils.loadInfo(usr, 'previousVendor') except KeyError: print('Savefile is broken. Creating new savefile...') newGame(usr) print('Game save loaded.') try: if entities.player.location == entities.getLocation('Inventory'): locations.inventory() elif entities.player.location == entities.getLocation('Market'): utils.goToVendor(previousVendor) elif entities.player.location == entities.getLocation('Interact'): utils.fight(entities.player.location.entity, entities.player.location.entity.weapon) inventory() else: commandLine() except KeyboardInterrupt or EOFError: sys.exit(1)