Example #1
0
 def execute(self):
     """ Override this method to get unique action
     However, this general template should be followed"""
     print("\nYou have reached the PlayerAction master class.\n")
     actions = ['whip', 'nae nae', 'back']
     action_dict = {}
     user_prompt(self.story, actions)
Example #2
0
 def remove_system(self):
     print("\nWhich system would you like to remove?\n")
     choice = user_prompt(self.story, self.story.show_systems(silent=True))
     if choice is not None:
         print("\nSystem ",
               self.story.systems.pop(choice)['name'], " deleted.")
     self.execute(
     )  #  This should be at the end of each action except 'back'
Example #3
0
def game_loop(player):
    try:
        while True:
            print('\nSelect one of these options:\n')
            choice = user_prompt(player.story, player.actions)
            if choice is not None:
                player.actions[choice].execute()
    except KeyboardInterrupt:
        player.story.save()
        print("\nGoodbye.")
Example #4
0
 def expand_system(self):
     print("\nChoose a system")
     actions = self.story.show_systems(silent=True)
     choice = user_prompt(self.story, actions)
     if choice is not None:
         try:
             print("Well, the rabbit hole seems closed for now")
         except:
             pass
     self.execute()
Example #5
0
 def delete_challenge(self):
     saves = self.story.show_saves(silent=True)
     print("\nWhich would you like to delete?\n")
     choice = user_prompt(self.story, saves)
     if choice is not None:
         dlt_file = "src/saves/challenges/" + saves[choice]
         if os.path.isfile(dlt_file):
             os.remove(dlt_file)
             print("'", dlt_file, "' was deleted.")
         else:
             print("  ", file, "doesn't exist to delete.")
     self.execute(
     )  #  This should be at the end of each action except 'back'
Example #6
0
 def switch_challenge(self):
     self.story.save()
     print("\nWhich challenge do you want to switch to?\n")
     actions = self.story.show_saves(silent=True)
     choice = user_prompt(self.story, actions)
     if choice is not None:
         try:
             self.story.load(actions[choice].lower())
         except FileNotFoundError:
             print("You can only switch to challenges that already exist.")
         except PermissionError:
             print("You do not have the permissions to do this.")
     self.execute(
     )  #  This should be at the end of each action except 'back'
Example #7
0
 def execute(self):
     print("\nFile Menu\n")
     actions = [
         'delete challenge', 'new challenge', 'save as', 'switch challenge',
         'back'
     ]
     action_dict = {
         0: self.delete_challenge,
         1: self.new_challenge,
         2: self.save_progress_as,
         3: self.switch_challenge,
         4: self.back
     }
     choice = user_prompt(self.story, actions)
     if choice is not None:
         action_dict.get(choice)()
     else:
         self.execute()
Example #8
0
 def execute(self):
     print("\nSystems Menu\n")
     actions = [
         'display systems', 'expand system', 'add system', 'remove system',
         'back'
     ]
     action_dict = {
         0: self.display_systems,
         1: self.expand_system,
         2: self.add_system,
         3: self.remove_system,
         4: self.back
     }
     choice = user_prompt(self.story, actions)
     if choice is not None:
         action_dict.get(choice)()
     else:
         self.execute(
         )  #  This should be at the end of each action except 'back'