Exemplo n.º 1
0
 def from_other_category(self, fruit, prev_menu):
     """ Pick a fruit requested from a different menu. """
     print(f"Do you want {fruit}? (yes/no)")
     while True:
         s = input()
         if s == "yes":
             print("Here we go then.")
             raise mofloc.ChangeFlow(TopLevel(), CONTINUE, "fruit", fruit)
         if s == "no":
             print("OK, taking you to the previous menu...")
             raise mofloc.ChangeFlow(prev_menu, START)
         print("yes/no only, please.")
Exemplo n.º 2
0
 def choose(self):
     """ Choose a category. """
     for cat in self.categories:
         print("* ", cat)
     while True:
         s = input("Category: ")
         if s not in self.categories:
             print("This is not in the list!")
             continue
         raise mofloc.ChangeFlow(self.categories[s], START)
Exemplo n.º 3
0
 def try_new_game(self, user_input):
     """
     If 'user_input' is a 'new game' command invokation, run the party
     creation flow, otherwise return False.
     """
     output = parse(self.parsers[mm.CMD_NEW_GAME], user_input)
     if output is None:
         return False
     import toi.stage.party_creation as party
     target_flow = party.PartyCreationFlow(self.io, self.data)
     raise mofloc.ChangeFlow(target_flow, party.FROM_MAIN_MENU)
Exemplo n.º 4
0
 def try_abort(self, user_input):
     """
     If 'user_input' is an 'abort' command invokation, return to the main
     menu, otherwise return False.
     """
     output = parse(self.game.common_parsers[common.CMD_ABORT], user_input)
     if output is None:
         return False
     import toi.stage.main_menu as mm
     self.io.say(self.data.strings[cat.COMMON][common.OKAY])
     target = mm.MainMenuFlow(self.io, self.data)
     raise mofloc.ChangeFlow(target, mm.FROM_PARTY_CREATION)
Exemplo n.º 5
0
 def start(self):
     """ Pick a fruit. """
     print("Following fruit are available:")
     for fruit in FRUIT:
         print("* ", fruit)
     while True:
         s = input("Pick a fruit: ")
         if s not in FRUIT:
             if s in VEGETABLE:
                 print(
                     "This is not a fruit, but a vegetable. Changing the menu to vegetables..."
                 )
                 raise mofloc.ChangeFlow(Vegetable(), OTHER_CAT, s, self)
             if s in SPICE:
                 print(
                     "This is not a fruit, but a spice. Changing the menu to spices..."
                 )
                 raise mofloc.ChangeFlow(Spice(), OTHER_CAT, s, self)
             print("This is not in the list, try again.")
             continue
         print(f"Here's your fruit: {s}")
         raise mofloc.ChangeFlow(TopLevel(), CONTINUE, "fruit", s)
Exemplo n.º 6
0
def init_game(ui_type):
    """ Initialize the game. """
    data = GameData()
    state = game_state_from_scratch(data)
    spawner = make_spawner(ui_type)
    raise mofloc.ChangeFlow(mm.MainMenu(state, spawner), None)
Exemplo n.º 7
0
def _start():
    """ Perform the setup. """
    data = GameData()
    io = _init_io()
    next_flow = mm.MainMenuFlow(io, data)
    raise mofloc.ChangeFlow(next_flow, mm.FROM_STARTUP)