コード例 #1
0
def at_server_start():
    """
    This is called every time the server starts up, regardless of
    how it was shut down.
    """
    # reload keys
    OBJECT_KEY_HANDLER.reload()

    # reset default locations
    builder.reset_default_locations()
    
    # clear dialogues
    DIALOGUE_HANDLER.clear()

    # clear quest dependencies
    QUEST_DEP_HANDLER.clear()

    # reload equipment types
    EQUIP_TYPE_HANDLER.reload()

    # reload local strings
    LOCALIZED_STRINGS_HANDLER.reload()

    # reload skill modules
    MudderySkill.load_skill_modules()
コード例 #2
0
def at_server_start():
    """
    This is called every time the server starts up, regardless of
    how it was shut down.
    """
    # reset settings
    GAME_SETTINGS.reset()
    CLIENT_SETTINGS.reset()

    # reload keys
    OBJECT_KEY_HANDLER.reload()

    # reset default locations
    builder.reset_default_locations()

    # clear dialogues
    DIALOGUE_HANDLER.clear()

    # clear quest dependencies
    QUEST_DEP_HANDLER.clear()

    # reload equipment types
    EQUIP_TYPE_HANDLER.reload()

    # reload local strings
    LOCALIZED_STRINGS_HANDLER.reload()

    # localize model fields
    localize_model_fields()
コード例 #3
0
def at_server_start():
    """
    This is called every time the server starts up, regardless of
    how it was shut down.
    """
    # reset settings
    GAME_SETTINGS.reset()

    # reload keys
    OBJECT_KEY_HANDLER.reload()

    # reset default locations
    builder.reset_default_locations()
    
    # clear dialogues
    DIALOGUE_HANDLER.clear()

    # clear quest dependencies
    QUEST_DEP_HANDLER.clear()

    # reload equipment types
    EQUIP_TYPE_HANDLER.reload()

    # reload local strings
    LOCALIZED_STRINGS_HANDLER.reload()

    # localize model fields
    localize_model_fields()
コード例 #4
0
    def get_default_sentences(self, caller, npc):
        """
        """
        if not caller:
            return

        if not npc:
            return

        sentences = []

        # get npc's default dialogues
        for dlg_key in npc.dialogues:
            npc_dlg = self.get_dialogue(dlg_key)
            if not npc_dlg:
                continue

            if not script_handler.match_condition(caller,
                                                  npc_dlg["condition"]):
                continue

            match = True
            for dep in npc_dlg["dependences"]:
                if not QUEST_DEP_HANDLER.match_dependence(
                        caller, dep["quest"], dep["type"]):
                    match = False
                    break
            if not match:
                continue

            if npc_dlg["sentences"]:
                # if has sentence, use it
                sentences.append(npc_dlg["sentences"][0])

        return sentences
コード例 #5
0
ファイル: dialogue_handler.py プロジェクト: JaffeLiu/muddery
    def get_default_sentences(self, caller, npc):
        """
        """
        if not caller:
            return

        if not npc:
            return

        sentences = []

        # get npc's default dialogues
        for dlg_key in npc.dialogues:
            npc_dlg = self.get_dialogue(dlg_key)
            if not npc_dlg:
                continue

            if not script_handler.match_condition(caller, npc_dlg["condition"]):
                continue

            match = True
            for dep in npc_dlg["dependences"]:
                if not QUEST_DEP_HANDLER.match_dependence(caller, dep["quest"], dep["type"]):
                    match = False
                    break;
            if not match:
                continue

            if npc_dlg["sentences"]:
                # if has sentence, use it
                sentences.append(npc_dlg["sentences"][0])

        return sentences
コード例 #6
0
def at_server_start():
    """
    This is called every time the server starts up, regardless of
    how it was shut down.
    """
    # reset settings
    GAME_SETTINGS.reset()

    # reload keys
    OBJECT_KEY_HANDLER.reload()

    # reload attributes
    CHARACTER_ATTRIBUTES_INFO.reload()
    EQUIPMENT_ATTRIBUTES_INFO.reload()
    FOOD_ATTRIBUTES_INFO.reload()

    # reset default locations
    builder.reset_default_locations()

    # clear dialogues
    DIALOGUE_HANDLER.clear()

    # clear quest dependencies
    QUEST_DEP_HANDLER.clear()

    # reload equipment types
    EQUIP_TYPE_HANDLER.reload()

    # reload local strings
    LOCALIZED_STRINGS_HANDLER.reload()

    # localize model fields
    localize_model_fields()

    # set character attribute field names
    CHARACTER_ATTRIBUTES_INFO.set_model_fields()
    EQUIPMENT_ATTRIBUTES_INFO.set_model_fields()
    FOOD_ATTRIBUTES_INFO.set_model_fields()

    # load condition descriptions
    DESC_HANDLER.reload()

    # load honours
    HONOURS_MAPPER.reload()
コード例 #7
0
    def dialogue_have_quest(self, caller, npc, dialogue, achieved_quests):
        """
        find quests by recursion
        """
        provide_quest = False
        finish_quest = False

        # check if the dialogue is available
        npc_dlg = self.get_dialogue(dialogue)
        if not npc_dlg:
            return (provide_quest, finish_quest)

        if not script_handler.match_condition(caller, npc_dlg["condition"]):
            return (provide_quest, finish_quest)

        match = True
        for dep in npc_dlg["dependences"]:
            if not QUEST_DEP_HANDLER.match_dependence(caller, dep["quest"],
                                                      dep["type"]):
                match = False
                break
        if not match:
            return (provide_quest, finish_quest)

        # find quests in its sentences
        for sen in npc_dlg["sentences"]:
            if sen["finish_quest"] in achieved_quests:
                finish_quest = True
                return (provide_quest, finish_quest)

            if not provide_quest and sen["provide_quest"]:
                quest_key = sen["provide_quest"]
                if not caller.quest.is_finished(quest_key) and\
                   not caller.quest.is_in_progress(quest_key) and\
                   caller.quest.match_dependences(quest_key):
                    provide_quest = True
                    if not achieved_quests:
                        return (provide_quest, finish_quest)

        for dlg_key in npc_dlg["nexts"]:
            # get next dialogue
            provide, finish = self.dialogue_have_quest(caller, npc, dlg_key,
                                                       achieved_quests)

            provide_quest = (provide_quest or provide)
            finish_quest = (finish_quest or finish)

            if finish_quest:
                break

            if not achieved_quests:
                if provide_quest:
                    break

        return (provide_quest, finish_quest)
コード例 #8
0
    def match_dependencies(self, quest_key):
        """
        Check quest's dependencies

        Args:
            quest_key: (string) quest's key

        Returns:
            (boolean) result
        """
        return QUEST_DEP_HANDLER.match_quest_dependencies(self.owner, quest_key)
コード例 #9
0
ファイル: quest_handler.py プロジェクト: noahzaozao/muddery
    def match_dependencies(self, quest):
        """
        Check quest's dependencies

        Args:
            quest: (string) quest's key

        Returns:
            None
        """
        return QUEST_DEP_HANDLER.match_quest_dependencies(self.owner, quest)
コード例 #10
0
    def get_npc_sentences(self, caller, npc):
        """
        Get NPC's sentences that can show to the caller.

        Args:
            caller: (object) the character who want to start a talk.
            npc: (object) the NPC that the character want to talk to.

        Returns:
            sentences: (list) a list of available sentences.
        """
        if not caller:
            return

        if not npc:
            return

        sentences = []

        # Get npc's dialogues.
        for dlg_key in npc.dialogues:
            # Get all dialogues.
            npc_dlg = self.get_dialogue(dlg_key)
            if not npc_dlg:
                continue

            # Match conditions.
            if not STATEMENT_HANDLER.match_condition(npc_dlg["condition"],
                                                     caller, npc):
                continue

            # Match dependencies.
            match = True
            for dep in npc_dlg["dependencies"]:
                if not QUEST_DEP_HANDLER.match_dependency(
                        caller, dep["quest"], dep["type"]):
                    match = False
                    break
            if not match:
                continue

            if npc_dlg["sentences"]:
                # If has sentence, use it.
                sentences.append(npc_dlg["sentences"][0])

        if not sentences:
            # Use default sentences.
            # Default sentences should not have condition and dependencies.
            for dlg_key in npc.default_dialogues:
                npc_dlg = self.get_dialogue(dlg_key)
                if npc_dlg:
                    sentences.append(npc_dlg["sentences"][0])

        return sentences
コード例 #11
0
    def dialogue_have_quest(self, caller, npc, dialogue, accomplished_quests):
        """
        Find quests by recursion.
        """
        provide_quest = False
        complete_quest = False

        # check if the dialogue is available
        npc_dlg = self.get_dialogue(dialogue)
        if not npc_dlg:
            return (provide_quest, complete_quest)

        if not STATEMENT_HANDLER.match_condition(npc_dlg["condition"], caller,
                                                 npc):
            return (provide_quest, complete_quest)

        match = True
        for dep in npc_dlg["dependencies"]:
            if not QUEST_DEP_HANDLER.match_dependency(caller, dep["quest"],
                                                      dep["type"]):
                match = False
                break
        if not match:
            return (provide_quest, complete_quest)

        # find quests in its sentences
        for sen in npc_dlg["sentences"]:
            if sen["complete_quest"] in accomplished_quests:
                complete_quest = True
                return (provide_quest, complete_quest)

            if not provide_quest and sen["provide_quest"]:
                quest_key = sen["provide_quest"]
                if caller.quest_handler.can_provide(quest_key):
                    provide_quest = True
                    if not accomplished_quests:
                        return (provide_quest, complete_quest)

        for dlg_key in npc_dlg["nexts"]:
            # get next dialogue
            provide, complete = self.dialogue_have_quest(
                caller, npc, dlg_key, accomplished_quests)

            provide_quest = (provide_quest or provide)
            complete_quest = (complete_quest or complete)

            if complete_quest:
                break

            if not accomplished_quests:
                if provide_quest:
                    break

        return (provide_quest, complete_quest)
コード例 #12
0
ファイル: dialogue_handler.py プロジェクト: JaffeLiu/muddery
    def dialogue_have_quest(self, caller, npc, dialogue, achieved_quests):
        """
        find quests by recursion
        """
        provide_quest = False
        finish_quest = False

        # check if the dialogue is available
        npc_dlg = self.get_dialogue(dialogue)
        if not npc_dlg:
            return (provide_quest, finish_quest)

        if not script_handler.match_condition(caller, npc_dlg["condition"]):
            return (provide_quest, finish_quest)

        match = True
        for dep in npc_dlg["dependences"]:
            if not QUEST_DEP_HANDLER.match_dependence(caller, dep["quest"], dep["type"]):
                match = False
                break;
        if not match:
            return (provide_quest, finish_quest)

        # find quests in its sentences
        for sen in npc_dlg["sentences"]:
            if sen["finish_quest"] in achieved_quests:
                finish_quest = True
                return (provide_quest, finish_quest)

            if not provide_quest and sen["provide_quest"]:
                quest_key = sen["provide_quest"]
                if not caller.quest.is_finished(quest_key) and\
                   not caller.quest.is_in_progress(quest_key) and\
                   caller.quest.match_dependences(quest_key):
                    provide_quest = True
                    if not achieved_quests:
                        return (provide_quest, finish_quest)

        for dlg_key in npc_dlg["nexts"]:
            # get next dialogue
            provide, finish = self.dialogue_have_quest(caller, npc, dlg_key, achieved_quests)
                
            provide_quest = (provide_quest or provide)
            finish_quest = (finish_quest or finish)

            if finish_quest:
                break

            if not achieved_quests:
                if provide_quest:
                    break

        return (provide_quest, finish_quest)
コード例 #13
0
ファイル: dialogue_handler.py プロジェクト: kickreg/muddery
    def get_npc_sentences(self, caller, npc):
        """
        Get NPC's sentences that can show to the caller.

        Args:
            caller: (object) the character who want to start a talk.
            npc: (object) the NPC that the character want to talk to.

        Returns:
            sentences: (list) a list of available sentences.
        """
        if not caller:
            return

        if not npc:
            return

        sentences = []

        # Get npc's dialogues.
        for dlg_key in npc.dialogues:
            # Get all dialogues.
            npc_dlg = self.get_dialogue(dlg_key)
            if not npc_dlg:
                continue

            # Match conditions.
            if not STATEMENT_HANDLER.match_condition(npc_dlg["condition"], caller, npc):
                continue

            # Match dependencies.
            match = True
            for dep in npc_dlg["dependencies"]:
                if not QUEST_DEP_HANDLER.match_dependency(caller, dep["quest"], dep["type"]):
                    match = False
                    break
            if not match:
                continue

            if npc_dlg["sentences"]:
                # If has sentence, use it.
                sentences.append(npc_dlg["sentences"][0])

        if not sentences:
            # Use default sentences.
            # Default sentences should not have condition and dependencies.
            for dlg_key in npc.default_dialogues:
                npc_dlg = self.get_dialogue(dlg_key)
                if npc_dlg:
                    sentences.append(npc_dlg["sentences"][0])
            
        return sentences
コード例 #14
0
    def dialogue_have_quest(self, caller, npc, dialogue, accomplished_quests):
        """
        Find quests by recursion.
        """
        provide_quest = False
        complete_quest = False

        # check if the dialogue is available
        npc_dlg = self.get_dialogue(dialogue)
        if not npc_dlg:
            return (provide_quest, complete_quest)

        if not SCRIPT_HANDLER.match_condition(caller, npc, npc_dlg["condition"]):
            return (provide_quest, complete_quest)

        match = True
        for dep in npc_dlg["dependencies"]:
            if not QUEST_DEP_HANDLER.match_dependency(caller, dep["quest"], dep["type"]):
                match = False
                break;
        if not match:
            return (provide_quest, complete_quest)

        # find quests in its sentences
        for sen in npc_dlg["sentences"]:
            if sen["complete_quest"] in accomplished_quests:
                complete_quest = True
                return (provide_quest, complete_quest)

            if not provide_quest and sen["provide_quest"]:
                quest_key = sen["provide_quest"]
                if caller.quest.can_provide(quest_key):
                    provide_quest = True
                    if not accomplished_quests:
                        return (provide_quest, complete_quest)

        for dlg_key in npc_dlg["nexts"]:
            # get next dialogue
            provide, complete = self.dialogue_have_quest(caller, npc, dlg_key, accomplished_quests)
                
            provide_quest = (provide_quest or provide)
            complete_quest = (complete_quest or complete)

            if complete_quest:
                break

            if not accomplished_quests:
                if provide_quest:
                    break

        return (provide_quest, complete_quest)
コード例 #15
0
    def get_next_sentences(self, caller, npc, current_dialogue,
                           current_sentence):
        """
        Get current sentence's next sentences.
        
        Args:
            caller: (object) the character who want to start a talk.
            npc: (object) the NPC that the character want to talk to.
            dialogue: (string) the key of the currrent dialogue.
            sentence: (int) the number of current sentence.

        Returns:
            sentences: (list) a list of available sentences.
        """
        if not caller:
            return

        # Get current dialogue.
        dlg = self.get_dialogue(current_dialogue)
        if not dlg:
            return

        sentences = []

        try:
            # If has next sentence, use next sentence.
            sentences.append(dlg["sentences"][current_sentence + 1])
        except Exception, e:
            # Else get next dialogues.
            for dlg_key in dlg["nexts"]:
                # Get next dialogue.
                next_dlg = self.get_dialogue(dlg_key)
                if not next_dlg:
                    continue

                if not next_dlg["sentences"]:
                    continue

                if not STATEMENT_HANDLER.match_condition(
                        next_dlg["condition"], caller, npc):
                    continue

                for dep in next_dlg["dependencies"]:
                    if not QUEST_DEP_HANDLER.match_dependency(
                            caller, dep["quest"], dep["type"]):
                        continue

                sentences.append(next_dlg["sentences"][0])
コード例 #16
0
    def get_sentences(self, caller, npc):
        """
        Get NPC's sentences.
        """
        if not caller:
            return

        if not npc:
            return

        sentences = []

        # Get npc's dialogues.
        for dlg_key in npc.dialogues:
            # Get all dialogues.
            npc_dlg = self.get_dialogue(dlg_key)
            if not npc_dlg:
                continue

            # Match conditions.
            if not SCRIPT_HANDLER.match_condition(caller, npc, npc_dlg["condition"]):
                continue

            # Match dependeces.
            match = True
            for dep in npc_dlg["dependencies"]:
                if not QUEST_DEP_HANDLER.match_dependency(caller, dep["quest"], dep["type"]):
                    match = False
                    break
            if not match:
                continue

            if npc_dlg["sentences"]:
                # If has sentence, use it.
                sentences.append(npc_dlg["sentences"][0])

        if not sentences:
            # Use default sentences.
            # Default sentences should not have condition and dependencies.
            for dlg_key in npc.default_dialogues:
                npc_dlg = self.get_dialogue(dlg_key)
                if npc_dlg:
                    sentences.append(npc_dlg["sentences"][0])
            
        return sentences
コード例 #17
0
ファイル: dialogue_handler.py プロジェクト: kickreg/muddery
    def get_next_sentences(self, caller, npc, current_dialogue, current_sentence):
        """
        Get current sentence's next sentences.
        
        Args:
            caller: (object) the character who want to start a talk.
            npc: (object) the NPC that the character want to talk to.
            dialogue: (string) the key of the currrent dialogue.
            sentence: (int) the number of current sentence.

        Returns:
            sentences: (list) a list of available sentences.
        """
        if not caller:
            return

        # Get current dialogue.
        dlg = self.get_dialogue(current_dialogue)
        if not dlg:
            return

        sentences = []

        try:
            # If has next sentence, use next sentence.
            sentences.append(dlg["sentences"][current_sentence + 1])
        except Exception, e:
            # Else get next dialogues.
            for dlg_key in dlg["nexts"]:
                # Get next dialogue.
                next_dlg = self.get_dialogue(dlg_key)
                if not next_dlg:
                    continue

                if not next_dlg["sentences"]:
                    continue

                if not STATEMENT_HANDLER.match_condition(next_dlg["condition"], caller, npc):
                    continue

                for dep in next_dlg["dependencies"]:
                    if not QUEST_DEP_HANDLER.match_dependency(caller, dep["quest"], dep["type"]):
                        continue

                sentences.append(next_dlg["sentences"][0])
コード例 #18
0
    def get_next_sentences(self, caller, npc, current_dialogue,
                           current_sentence):
        """
        """
        if not caller:
            return

        if not npc:
            return

        # get current dialogue
        dlg = self.get_dialogue(current_dialogue)
        if not dlg:
            return

        sentences = []

        try:
            # if has next sentence, use next sentence
            sentences.append(dlg["sentences"][current_sentence + 1])
        except Exception, e:
            # get next dialogues
            for dlg_key in dlg["nexts"]:
                # get next dialogue
                next_dlg = self.get_dialogue(dlg_key)
                if not next_dlg:
                    continue

                if not next_dlg["sentences"]:
                    continue

                if not script_handler.match_condition(caller,
                                                      next_dlg["condition"]):
                    continue

                for dep in next_dlg["dependences"]:
                    if not QUEST_DEP_HANDLER.match_dependence(
                            caller, dep["quest"], dep["type"]):
                        continue

                sentences.append(next_dlg["sentences"][0])
コード例 #19
0
ファイル: dialogue_handler.py プロジェクト: JaffeLiu/muddery
    def get_next_sentences(self, caller, npc, current_dialogue, current_sentence):
        """
        """
        if not caller:
            return

        if not npc:
            return

        # get current dialogue
        dlg = self.get_dialogue(current_dialogue)
        if not dlg:
            return

        sentences = []

        try:
            # if has next sentence, use next sentence
            sentences.append(dlg["sentences"][current_sentence + 1])
        except Exception, e:
            # get next dialogues
            for dlg_key in dlg["nexts"]:
                # get next dialogue
                next_dlg = self.get_dialogue(dlg_key)
                if not next_dlg:
                    continue

                if not next_dlg["sentences"]:
                    continue

                if not script_handler.match_condition(caller, next_dlg["condition"]):
                    continue

                for dep in next_dlg["dependences"]:
                    if not QUEST_DEP_HANDLER.match_dependence(caller, dep["quest"], dep["type"]):
                        continue

                sentences.append(next_dlg["sentences"][0])
コード例 #20
0
    def get_next_sentences(self, caller, npc, current_dialogue, current_sentence):
        """
        Get current sentence's next sentences.
        """
        if not caller:
            return

        # Get current dialogue.
        dlg = self.get_dialogue(current_dialogue)
        if not dlg:
            return

        sentences = []

        try:
            # If has next sentence, use next sentence.
            sentences.append(dlg["sentences"][current_sentence + 1])
        except Exception, e:
            # Else get next dialogues.
            for dlg_key in dlg["nexts"]:
                # Get next dialogue.
                next_dlg = self.get_dialogue(dlg_key)
                if not next_dlg:
                    continue

                if not next_dlg["sentences"]:
                    continue

                if not SCRIPT_HANDLER.match_condition(caller, npc, next_dlg["condition"]):
                    continue

                for dep in next_dlg["dependencies"]:
                    if not QUEST_DEP_HANDLER.match_dependency(caller, dep["quest"], dep["type"]):
                        continue

                sentences.append(next_dlg["sentences"][0])
コード例 #21
0
ファイル: quest_handler.py プロジェクト: JaffeLiu/muddery
 def match_dependences(self, quest):
     """
     check quest's dependences
     """
     return QUEST_DEP_HANDLER.match_quest_dependences(self.character, quest)
コード例 #22
0
 def match_dependences(self, quest):
     """
     check quest's dependences
     """
     return QUEST_DEP_HANDLER.match_quest_dependences(self.character, quest)