示例#1
0
    def try_done(self, user_input):
        """
        If 'user_input' is a 'done' command invokation, add the generated
        character to the party and end the flow - if the information is
        complete and background and species were selected. If some info is
        missing, say so and return True.

        Otherwise, return False.
        """
        output = parse(self.parsers[char.CMD_DONE], user_input)
        if output is None:
            return False
        if self.background is None:
            self.io.say(self.data.strings[cat.CHAR_CREATION][char.SELECT_BG])
            return True
        if self.species is None:
            self.io.say(self.data.strings[cat.CHAR_CREATION][char.SELECT_SPECIES])
            return True
        prompt = self.data.strings[cat.CHAR_CREATION][char.IS_OK_PROMPT]
        prompt = prompt.format(overview=self.overview())
        response = cstage.yesno(
            prompt,
            self.data.strings[cat.COMMON][common.JUST_YESNO],
            self.game.common_parsers,
            self.io)
        if response is cstage.Response.NO:
            return True
        if self.pc is None:
            player = PlayerCharacter(self.name, self.species, self.background)
            self.game.party.add_character(player)
        else:
            self.pc.set_name(self.name)
            self.pc.change_species(self.species)
            self.pc.change_background(self.background)
        raise mofloc.EndFlow
示例#2
0
 def try_overview(self, user_input):
     """
     If 'user_input' is an 'overview' command invokation, print out an
     overview of the character being created.
     """
     output = parse(self.parsers[char.CMD_OVERVIEW], user_input)
     if output is None:
         return False
     self.io.say(self.overview())
     return True
示例#3
0
文件: main_menu.py 项目: mpevnev/toi
 def try_greet(self, user_input):
     """
     If 'user_input' is a 'greet me' command invokation, greet the player
     one more time and return True, otherwise return False.
     """
     output = parse(self.parsers[mm.CMD_GREET], user_input)
     if output is None:
         return False
     self.io.say(self.data.strings[cat.MAIN_MENU][mm.GREETING])
     return True
示例#4
0
 def try_abort(self, user_input):
     """
     If 'user_input' is an 'abort' command invokation, end the flow.
     Otherwise return False.
     """
     output = parse(self.game.common_parsers[common.CMD_ABORT], user_input)
     if output is None:
         return False
     self.io.say(self.data.strings[cat.COMMON][common.OKAY])
     raise mofloc.EndFlow
示例#5
0
文件: main_menu.py 项目: mpevnev/toi
 def try_quit(self, user_input):
     """
     If 'user_input' is a 'quit' command invokation, quit the game,
     otherwise return False.
     """
     output = parse(self.game.common_parsers[common.CMD_QUIT], user_input)
     if output is None:
         return False
     self.io.say(self.data.strings[cat.COMMON][common.FAREWELL])
     self.io.flush()
     raise mofloc.EndFlow
示例#6
0
文件: main_menu.py 项目: mpevnev/toi
 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)
示例#7
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)
示例#8
0
 def try_list_bgs(self, user_input):
     """
     If 'user_input' is a 'list bgs' command invokation, list available
     backgrounds and return True, otherwise return False.
     """
     output = parse(self.parsers[char.CMD_LIST_BGS], user_input)
     if output is None:
         return False
     for bg in self.data.backgrounds:
         prefix = self.data.strings[cat.COMMON][common.LIST_PREFIX]
         self.io.say(prefix, bg.name)
     return True
示例#9
0
 def try_add(self, user_input):
     """
     If 'user_input' is an 'add' command invokation, start a
     CharCreationFlow subflow and then return True, otherwise return False.
     """
     output = parse(self.parsers[party.CMD_ADD], user_input)
     if output is None:
         return False
     subflow = charstage.CharCreationFlow(self.io, self.data, self.game)
     mofloc.execute(subflow, charstage.CREATE_NEW)
     self.welcome_back()
     return True
示例#10
0
 def try_list_species(self, user_input):
     """
     If 'user_input' is a 'list species' command invokation, list available
     species and return True, otherwise return False.
     """
     output = parse(self.parsers[char.CMD_LIST_SPECIES], user_input)
     if output is None:
         return False
     for species in self.data.species:
         prefix = self.data.strings[cat.COMMON][common.LIST_PREFIX]
         self.io.say(prefix, species.name)
     return True
示例#11
0
 def try_set_species(self, user_input):
     """
     If 'user_input' is a 'set species' command invokation, set the species
     of the character being created to the value captured by the parser.
     """
     output = parse(self.parsers[char.CMD_SET_SPECIES], user_input)
     if output is None:
         return False
     species = output[Capture.SPECIES]
     if species is None:
         self.io.say(self.data.strings[cat.CHAR_CREATION][char.NOT_A_VALID_SPECIES])
         return True
     self.species = species
     return True
示例#12
0
 def try_set_name(self, user_input):
     """
     If 'user_input' is a 'set name' command invokation, set the name of the
     character being edited or created.
     """
     output = parse(self.parsers[char.CMD_SET_NAME], user_input)
     if output is None:
         return False
     name = misc.pretty_name(output[Capture.NAME])
     self.name = name
     msg = self.data.strings[cat.CHAR_CREATION][char.NEW_NAME_IS]
     msg = msg.format(name=name)
     self.io.say(msg)
     return True
示例#13
0
 def try_set_bg(self, user_input):
     """
     If 'user_input' is a 'set bg' command invokation, set the background of
     the character being created to the value captured by the parser.
     """
     output = parse(self.parsers[char.CMD_SET_BG], user_input)
     if output is None:
         return False
     bg = output[Capture.BACKGROUND]
     if bg is None:
         self.io.say(self.data.strings[cat.CHAR_CREATION][char.NOT_A_VALID_BG])
         return True
     self.background = bg
     return True
示例#14
0
 def try_change_name(self, user_input):
     """
     If 'user_input' is a 'change name' command invokation, change party's
     name, print it out and return True, otherwise return False.
     """
     output = parse(self.parsers[party.CMD_CHANGE_PARTY_NAME], user_input)
     if output is None:
         return False
     name = misc.pretty_name(output[Capture.NAME])
     self.game.party.name = name
     msg = self.data.strings[cat.PARTY_CREATION][party.NEW_NAME_IS]
     msg = msg.format(party_name=name)
     self.io.say(msg)
     return True
示例#15
0
 def try_delete(self, user_input):
     """
     If 'user_input' is a 'delete' command invokation, delete the specified
     character from the party and return True, otherwise return False.
     """
     output = parse(self.parsers[party.CMD_DELETE], user_input)
     if output is None:
         return False
     if output[Capture.PC] is None:
         self.io.say(self.data.strings[cat.COMMON][common.NO_SUCH_CHAR])
         return True
     self.game.party.delete_character(output[Capture.PC])
     msg = self.data.strings[cat.PARTY_CREATION][party.DONE_DELETING]
     msg = msg.format(deleted_pc=output[Capture.PC].name)
     self.io.say(msg)
     return True
示例#16
0
 def try_edit(self, user_input):
     """
     If 'user_input' is an 'edit' command invokation, edit a specified
     character using CharCreationFlow and then return True, otherwise return
     False.
     """
     output = parse(self.parsers[party.CMD_EDIT], user_input)
     if output is None:
         return False
     if output[Capture.PC] is None:
         self.io.say(
             self.data.strings[cat.PARTY_CREATION][party.NO_SUCH_CHARACTER])
         return True
     subflow = charstage.CharCreationFlow(self.io, self.data, self.game)
     mofloc.execute(subflow, charstage.EDIT_EXISTING, output[Capture.PC])
     self.welcome_back()
     return True
示例#17
0
 def try_quit(self, user_input):
     """
     If 'user_input' is a 'quit' command invokation, quit the game,
     otherwise return False.
     """
     output = parse(self.game.common_parsers[common.CMD_QUIT], user_input)
     if output is None:
         return False
     if self.game.party is None:
         farewell = self.data.strings[cat.COMMON][common.FAREWELL]
     else:
         farewell = self.data.strings[cat.COMMON][
             common.FAREWELL_WITH_PARTY]
         farewell = farewell.format(party_name=self.game.party.name)
     self.io.say(farewell)
     self.io.flush()
     raise mofloc.EndFlow
示例#18
0
 def try_overview(self, user_input):
     """
     If 'user_input' is a 'list' command invokation, print party's name and
     short info on each character, then return True, otherwise return False.
     """
     output = parse(self.parsers[party.CMD_OVERVIEW], user_input)
     if output is None:
         return False
     strings = self.data.strings[cat.PARTY_CREATION]
     self.io.say(
         strings[party.NAME_IS].format(party_name=self.game.party.name))
     try:
         _ = self.game.party.characters[0]
         empty = False
     except IndexError:
         empty = True
     if empty:
         self.io.say(strings[party.EMPTY_PARTY])
     else:
         self.io.say(strings[party.LIST_OF_CHARS])
         for pc in self.game.party.characters:
             prefix = self.data.strings[cat.COMMON][common.LIST_PREFIX]
             self.io.say(prefix, pc.short_description(self.data.strings))
     return True