def processDialogue(dialogue, game_state): """ Process a L{Dialogue} until the user selects a response that ends it. @param dialogue: dialogue data to process. @type dialogue: L{Dialogue} @param game_state: objects that should be made available for response conditional testing. @type game_state: dict of objects """ npc_name = dialogue.npc_name dialogue_processor = DialogueProcessor(dialogue, game_state) dialogue_processor.initiateDialogue() while dialogue_processor.in_dialogue: responses = dialogue_processor.continueDialogue() current_dialogue_section = \ dialogue_processor.getCurrentDialogueSection() dialogue_text = current_dialogue_section.text # Indent dialogue text after the first line. dialogue_text = dialogue_text.replace('\n', '\n ') print('\n{0}: {1}'.format(npc_name, dialogue_text)) chosen_reply = chooseReply(responses) dialogue_processor.reply(chosen_reply)