Ejemplo n.º 1
0
    def continue_dialogue(self, npc, dialogue, sentence):
        """
        Continue current dialogue.

        Args:
            npc: (optional) NPC's object.
            dialogue: current dialogue's key.
            sentence: current sentence's ordinal.

        Returns:
            None
        """
        if GAME_SETTINGS.get("auto_resume_dialogues"):
            # Check current dialogue.
            if not self.db.current_dialogue:
                return

            if (dialogue,
                    sentence) not in self.db.current_dialogue["sentences_all"]:
                # Can not find specified dialogue in current dialogues.
                return

        try:
            # Finish current sentence
            DIALOGUE_HANDLER.finish_sentence(self, npc, dialogue, sentence)
        except Exception as e:
            ostring = "Can not finish sentence %s-%s: %s" % (dialogue,
                                                             sentence, e)
            logger.log_tracemsg(ostring)

        # Get next sentences.
        sentences = DIALOGUE_HANDLER.get_next_sentences(
            self, npc, dialogue, sentence)

        # Send dialogues_list to the player.
        self.save_current_dialogue(sentences, npc)
        self.msg({"dialogue": sentences})
        if not sentences:
            # dialogue finished, refresh surroundings
            self.show_location()
Ejemplo n.º 2
0
            pass

        if have_current_dlg:
            try:
                # Finish this sentence
                DIALOGUE_HANDLER.finish_sentence(caller,
                                                 dialogue,
                                                 sentence)
            except Exception, e:
                ostring = "Can not finish sentence %s-%s: %s" % (dialogue, sentence, e)
                logger.log_errmsg(ostring)
                logger.log_errmsg(traceback.format_exc())

        # Get next sentence.
        sentences = DIALOGUE_HANDLER.get_next_sentences(caller,
                                                        npc,
                                                        dialogue,
                                                        sentence)

        if sentences:
            speaker = sentences[0]["speaker"];
            if speaker == "n":
                speaker = npc.get_name()
            elif speaker == "p":
                speaker = caller.get_name()
            elif speaker[0] == '"' and speaker[-1] == '"':
                speaker = speaker[1:-1]

        dialogues = []
        for s in sentences:
            dlg = {"speaker": speaker,
                   "npc": npc.key,
Ejemplo n.º 3
0
            pass

        if have_current_dlg:
            try:
                # Finish current sentence
                DIALOGUE_HANDLER.finish_sentence(caller,
                                                 npc,
                                                 dialogue,
                                                 sentence)
            except Exception, e:
                ostring = "Can not finish sentence %s-%s: %s" % (dialogue, sentence, e)
                logger.log_tracemsg(ostring)

        # Get next sentence.
        sentences = DIALOGUE_HANDLER.get_next_sentences(caller,
                                                        npc,
                                                        dialogue,
                                                        sentence)

        # Get speaker's name.
        speaker = ""
        if sentences:
            speaker = DIALOGUE_HANDLER.get_dialogue_speaker(caller, npc, sentences[0]["speaker"])

        dialogues = []
        for s in sentences:
            dlg = {"speaker": speaker,          # speaker's name
                   "dialogue": s["dialogue"],   # dialogue's key
                   "sentence": s["sentence"],   # sentence's ordinal
                   "content": s["content"]}     # sentence's content
            if npc:
                dlg["npc"] = npc.dbref          # NPC's dbref, if has NPC.