Esempio n. 1
0
def wait_check_fight(call, tmin, tmax, cond=0):
    global first_fight
    sleep(uniform(tmin, tmax))
    if useful['infight'] and cond != -1:
        fight(call, first_fight)
        first_fight = False
        print("out")
Esempio n. 2
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)
Esempio n. 3
0
def personInteraction():
    entities.player.location = entities.getLocation('Interact')
    personType = random.randint(1, 3)
    if personType == 1:
        person = [random.choice(entities.enemies), random.choice(entities.weapons)]
        if utils.confirm('You see a mean-looking person in the distance. Do you choose to approach?'):
            utils.fight(person[0], person[1])
        else:
            print('You run away in fear.')
    elif personType == 2:
        if entities.worldEntities:
            person = random.choice(entities.worldEntities)
            person.inventory.append(random.choice(entities.weapons))
            if utils.confirm('You see a familiar, mean-looking person in the distance. Do you choose to approach?'):
                utils.fight(person, person.inventory[0])
            else:
                print('You run away in fear.')
        else:
            person = random.choice(entities.enemies)
            person.inventory.append(random.choice(entities.weapons))
            if utils.confirm('You see a mean-looking person in the distance. Do you choose to approach?'):
                utils.fight(person, person.inventory[0])
            else:
                print('You run away in fear.')
    else:
        person = [random.choice(entities.helpers), random.choice(entities.helperItems)]
        if utils.confirm('You see a kind-looking person in the distance. Do you choose to approach?'):
            print('The person is a(n) ' + person[0].name + '!')
            if person[0] == entities.getHelper('old lady'):
                if random.randint(0,1) == 0:
                    utils.fight(entities.getEnemy('old lady'), entities.getWeapon('cane'))
                else:
                    time.sleep(0.5)
                    print('The %s smiles and holds a(n) %s out in her hand.' % (person[0].name, person[1].name))
                    entities.player.inventory.append(person[1])
                    time.sleep(0.2)
                    print(person[1].name + ' added to your inventory!')
            else:
                time.sleep(0.5)
                print('The %s smiles and holds a(n) %s out in her hand.' % (person[0].name, person[1].name))
                entities.player.inventory.append(person[1])
                time.sleep(0.2)
                print(person[1].name + ' added to your inventory!')
        else:
            print('You walk away')
            time.sleep(2)
Esempio n. 4
0
def memory():
    while True:
        try:
            rand = random.randint(0,1)
            print(rand, end='')
        except KeyboardInterrupt:
            try:
                print('\nRegaining Train of Thought...\n')
                time.sleep(10)
            except KeyboardInterrupt:
                try:
                    print('\nEntering Subconcience...\n')
                    time.sleep(10)
                except KeyboardInterrupt:
                    print('\nProgress Lost.')
                    sys.exit(0)
                try:
                    while True:
                        command = input('ZZZ : ').split(' ')
                        if command[0].upper() == 'WAKE':
                            print('It cost 10 coins to wake.')
                            entities.player.spend(10)
                            return
                        elif command[0].upper() == 'LOADMOD':
                            if len(command) > 1:
                                os.system(command[1])
                            else:
                                print('Usage: loadmod <mod>')
                        elif command[0].upper() == 'VIEWMATRIX':
                            os.system('cat textbasedgame.py')
                            print('You are not here...')
                            time.sleep(5)
                            return
                            while True:
                                command = input('ZZZ/Matrix : ').split(' ')
                                if command[0].upper() == 'GOTO':
                                    print('Whoops')
                                    #print(str(open('textbasedgame.py', newline=None)).split('\n')[int(command[1])])
                        elif command[0].upper() == 'GET':
                            if len(command) > 2:
                                if len(command) < 4:
                                    if command[1].upper() == 'FOOD':
                                        entities.player.inventory.append(entities.getFood(command[2]))
                                    elif command[1].upper() == 'WEAPON':
                                        entities.player.inventory.append(entities.getWeapon(command[2]))
                                else:
                                    try:
                                        if command[1].upper() == 'FOOD':
                                            i = 0
                                            while i < int(command[3]):
                                                entities.player.inventory.append(entities.getFood(command[2]))
                                                i += 1
                                        elif command[1].upper() == 'WEAPON':
                                            i = 0
                                            while i < int(command[3]):
                                                entities.player.inventory.append(entities.getWeapon(command[2]))
                                                i += 1
                                    except ValueError:
                                        print('Usage:\tget <type> <object>\n\tget <type:food/weapon> <object> <amount>\nAmount must be integer.')
                            else:
                                print('"get" requires 3 arguments. Maximum: 4.')
                        elif command[0].upper() == 'GOTO':
                            if command[1].upper() == 'SLEEP':
                                print('Before you may sleep...')
                                time.sleep(2.5)
                                print('You must fight me...')
                                time.sleep(2.5)
                                print('I am you...')
                                time.sleep(2.5)
                                print('But you are not me.')
                                time.sleep(10)
                                utils.fight(entities.you, utils.getBestInventoryWeapon()[1])
                                sleep()
                except KeyboardInterrupt:
                    try:
                        print('\nRegaining Train of Thought...\n')
                        time.sleep(10)
                    except KeyboardInterrupt:
                        print('\nSuffered Memory Loss.\n')
                        rand = random.randint(0,2)
                        if rand == 0:
                            entities.player.inventory = []
                        elif rand == 1:
                            entities.player.money = 0
                        else:
                            entities.player.power = float(0)
                        return