def newGame(name=None): global usr, usrFile entities.worldEntities = [] if name != None: usr = name else: try: usr = input('What is your desired username? : ') usrFile = usr + '.save' # Add extension except KeyboardInterrupt: play() entities.player = obj.Player(usr, 100, 100, float(5)) entities.player.inventory = [entities.getWeapon('stick'), entities.getFood('potato')] entities.player.location = entities.getLocation('Main') print('New game set up. Welcome.') commandLine()
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