| Trees | Indices | Help |
|---|
|
|
object --+
|
DialogueProcessor
Primary interface to the dialogue subsystem used to initiate and process a Dialogue with an NPC.
To begin a dialogue with an NPC a DialogueProcessor must first be instantiated with the
dialogue data to process and a dictionary of Python objects defining the
game state for testing of response conditionals. The initiateDialogue must be called to initialized the DialogueProcessor, and once it is initialized processing
of DialogueSections and DialogueResponses can be initiated via the continueDialogue and reply class methods.
The state of dialogue processing is stored via the dialogue_section_stack class attribute, which stores a
list of DialogueSections that have been or are
currently being processed. Each time reply is called with a DialogueResponse its next_section_id attribute is
used to select a new DialogueSection from the
dialogue. The selected DialogueSection is then pushed onto the end of the dialogue_section_stack, ready to be processed via continueDialogue. The exception to this rule occurs when
reply is called with a DialogueResponse whose next_section_id attribute is
"end" or "back". "end" terminates the
dialogue as described below, while "back" removes the last
DialogueSection on the dialogue_section_stack effectively going back to the
previous section of dialogue.
The DialogueProcessor terminates dialogue processing once reply is called with a DialogueResponse whose next_section_id == 'end'.
Processing can also be manually terminated by calling the endDialogue class method.
Note: See the dialogue_demo.py script for a complete example of how the DialogueProcessor can be used.
|
|||
|
|||
DialogueSection
|
|
||
|
|||
|
|||
DialogueSection
|
|
||
|
|||
list of DialogueResponses
|
|
||
|
|||
|
|||
|
Inherited from |
|||
|
|||
_logger = logging.getLogger('dialogueengine.DialogueProcessor')
|
|||
|
|||
| Dialogue |
dialogue dialogue data currently being processed. |
||
list of DialogueSections
|
dialogue_section_stack sections of dialogue that have been or are currently being processed. |
||
| dict of Python objects |
game_state objects defining the game state that should be made available for testing DialogueResponse conditionals.
|
||
|
Bool
Usage: >>> game_state = {'pc': player_character, 'quest': quest_engine} >>> dialogue_processor = DialogueProcessor(dialogue, game_state) >>> dialogue_processor.initiateDialogue() >>> while dialogue_processor.in_dialogue: ... valid_responses = dialogue_processor.continueDialogue() ... response = choose_response(valid_responses) ... dialogue_processor.reply(response) |
in_dialogue whether a dialogue has been initiated. |
||
|
|||
|
Inherited from |
|||
|
|||
Initialize a new DialogueProcessor instance.
|
Evaluate the
|
Prepare the DialogueProcessor to process the Dialogue by
pushing the starting
|
Process the L{DialogueSection} at the top of the
L{dialogue_section_stack}, run any L{DialogueActions<DialogueActions>}
it contains and return a list of valid
L{DialogueResponses<DialogueResponses> after evaluating any response
conditionals.
@returns: valid responses.
@rtype: list of L{DialogueResponses<DialogueResponse>}
@raise RuntimeError: Any preconditions are not met.
@precondition: dialogue has been initiated via L{initiateDialogue}.
|
Return the
Precondition:
dialogue has been initiated via initiateDialogue and dialogue_section_stack contains at least one |
Execute all
|
Evaluate all
|
Reply with a
Precondition: initiateDialogue must be called before this method is used. |
|
|||
dialoguedialogue data currently being processed.
|
dialogue_section_stacksections of dialogue that have been or are currently being processed.
|
game_stateobjects defining the game state that should be made available for testingDialogueResponse conditionals.
|
in_dialoguewhether a dialogue has been initiated.
|
| Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Mon Aug 15 17:19:43 2011 | http://epydoc.sourceforge.net |