Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
def execute(command):
    if command[0] == '?' or command[0].upper() == 'HELP':
        print('Possible commands:')
        entities.getHelpMsg('Main').printMsg()
    elif command[0].upper() == 'GOTO':
        if command[1].upper() == 'INTERACT':
            locations.personInteraction()
        elif command[1].upper() == 'MARKET':
            print('Going to market...')
            locations.market()
        elif command[1].upper() == 'INVENTORY':
            print('Entering Inventory...')
            locations.inventory()
        elif command[1].upper() == 'MEMORY':
            locations.memory()
        else:
            print('Location not found.')
    else:
        print('Command not found. Type "help" or "?" for help.')