def splash_screen(): ''' display a simple splash screen which asks user to load/start game. ''' while True: print '"Load" existing game or "start" new game?' input_string = raw_input("load/start? ") if input_string == 'load' or input_string == 'l': player_game = GameInstance(load=DEFAULT_SAVE_FILE) upper_main(player_game) elif input_string == 'start' or input_string == 's': player_game = GameInstance() upper_main(player_game) # Just so I can test stuff. (Joshua) elif input_string == 'debug' or input_string == 'd': player_game = GameInstance() action_list = ['exit', 'take eggs from fridge', 'look inside fridge', 'go kitchen', 'go hallway'] # ^ Anyone know how I can have this work without it being backwards? refers to action_list.pop() below user_input.opening_setup(player_game,lambda (x): 'Joshua') counter = 1 while True: command = player_game.parser.parse(action_list.pop()) # next command print "%i: %s" % (counter, command.raw) player_game.take_action(command) player_game.check_events() counter += 1 else: invalid_input("Please enter \"load\" or \"start\"", input_string=input_string, tag='bad load/save choice')
def upper_main(player_game, input=raw_input): """ This loop should never exit. Exception: if the player specifies to exit """ user_input.opening_setup(player_game,input) while True: user_action = user_input.request_action(player_game,input) player_game.take_action(user_action)
def base_actions_test(self): ''' test to ensure that base actions don't crash ''' game = GameInstance() opening_setup(game,input=randomString) for action in BASE_ACTIONS: if action=="exit": # skip exit action (or else test breaks) continue elif action=="help": # ignore help continue else: game.take_action(action,input=randomString)
def __init__(self, load=False, input_func=user_input.default_input): if load == False: # define attributes: # self.player = Player("NoName", "Male", "Human", None) self.parser = Parser() self.config_loader = UnsuiConfigLoader() self.GAME_START = datetime.now() self.commands_entered = 0 self.actions_available = BASE_ACTIONS # call set up functions: # self.config_loader.generate() user_input.opening_setup(self,input=input_func) self.events_engine = EventsEngine.EventsEngine(getStartingEvents(self)) else: self.load_game(load)
def base_help_test(self): '''tests out the help for all base actions''' game = GameInstance() opening_setup(game,input=randomString) for action in BASE_ACTIONS: class pickAction(object): def __init__(self): self.choice = action def __call__(self,prompt): if self.choice == action: self.choice = 'back' return action elif self.choice == 'back': self.choice == None return 'back' else: raise Error('WAT') chooser = pickAction() help_info(input=chooser)
def random_setup_test(self): ''' runs through basic setup with random values to ensure it does not crash ''' game = GameInstance() opening_setup(game,input=randomString)