Example #1
0
    def construct(cls, type, uid, knowledge_base, hero, experience, power):

        writer = writers.get_writer(
            hero=hero, type=type, message=None, substitution=cls.substitution(uid, knowledge_base, hero)
        )

        actors = {
            participant.role: (knowledge_base[participant.participant].externals["id"], writer.actor(participant.role))
            for participant in knowledge_base.filter(facts.QuestParticipant)
            if participant.start == uid
        }

        return cls(
            type=type,
            uid=uid,
            name=writer.name(),
            action="",
            choice=None,
            choice_alternatives=[],
            experience=experience,
            power=power,
            experience_bonus=0,
            power_bonus=0,
            actors=actors,
            used_markers={},
        )
Example #2
0
    def process_message(self,
                        knowledge_base,
                        hero,
                        message,
                        ext_substitution={}):

        substitution = self.substitution(self.uid, knowledge_base, hero)
        substitution.update(ext_substitution)

        writer = writers.get_writer(hero=hero,
                                    type=self.type,
                                    message=message,
                                    substitution=substitution)

        action_msg = writer.action()
        if action_msg:
            self.action = action_msg

        diary_msg = writer.diary()
        if diary_msg:
            hero.push_message(diary_msg, diary=True, journal=True)
            return

        journal_msg = writer.journal()
        if journal_msg:
            hero.push_message(journal_msg, diary=False, journal=True)
Example #3
0
    def construct(cls, type, uid, knowledge_base, hero, experience, power):

        writer = writers.get_writer(hero=hero,
                                    type=type,
                                    message=None,
                                    substitution=cls.substitution(
                                        uid, knowledge_base, hero))

        actors = {
            participant.role:
            (knowledge_base[participant.participant].externals['id'],
             writer.actor(participant.role))
            for participant in knowledge_base.filter(facts.QuestParticipant)
            if participant.start == uid
        }

        return cls(type=type,
                   uid=uid,
                   name=writer.name(),
                   action='',
                   choice=None,
                   choice_alternatives=[],
                   experience=experience,
                   power=power,
                   experience_bonus=0,
                   power_bonus=0,
                   actors=actors,
                   used_markers={})
Example #4
0
    def _donothing(self, donothing_type):
        from the_tale.game.actions.prototypes import ActionDoNothingPrototype

        donothing = relations.DONOTHING_TYPE.index_value[donothing_type]

        writer = writers.get_writer(hero=self.hero, type=self.current_info.type, message=donothing_type, substitution={})

        ActionDoNothingPrototype.create(hero=self.hero,
                                        duration=donothing.duration,
                                        messages_prefix=writer.journal_id(),
                                        messages_probability=donothing.messages_probability)
Example #5
0
    def _donothing(self, donothing_type):
        from the_tale.game.actions.prototypes import ActionDoNothingPrototype

        donothing = relations.DONOTHING_TYPE.index_value[donothing_type]

        writer = writers.get_writer(hero=self.hero,
                                    type=self.current_info.type,
                                    message=donothing_type,
                                    substitution={})

        ActionDoNothingPrototype.create(
            hero=self.hero,
            duration=donothing.duration,
            messages_prefix=writer.journal_id(),
            messages_probability=donothing.messages_probability)
Example #6
0
    def process_message(self, knowledge_base, hero, message, ext_substitution={}):

        substitution = self.substitution(self.uid, knowledge_base, hero)
        substitution.update(ext_substitution)

        writer = writers.get_writer(hero=hero, type=self.type, message=message, substitution=substitution)

        action_msg = writer.action()
        if action_msg:
            self.action = action_msg

        diary_msg = writer.diary()
        if diary_msg:
            hero.push_message(diary_msg, diary=True, journal=True)
            return

        journal_msg = writer.journal()
        if journal_msg:
            hero.push_message(journal_msg, diary=False, journal=True)
Example #7
0
    def sync_choices(self, knowledge_base, hero, choice, options, defaults):

        if choice is None:
            self.choice = None
            self.choice_alternatives = ()
            return

        substitution = self.substitution(self.uid, knowledge_base, hero)
        writer = writers.get_writer(hero=hero, type=self.type, message='choice', substitution=substitution)

        choosen_option = knowledge_base[defaults[0].option]

        self.choice = writer.current_choice(choosen_option.type)

        if defaults[0].default:
            self.choice_alternatives = [(option.uid, writer.choice_variant(option.type))
                                        for option in options
                                        if option.uid != choosen_option.uid]
        else:
            self.choice_alternatives = ()
Example #8
0
    def sync_choices(self, knowledge_base, hero, choice, options, defaults):

        if choice is None:
            self.choice = None
            self.choice_alternatives = ()
            return

        substitution = self.substitution(self.uid, knowledge_base, hero)
        writer = writers.get_writer(hero=hero,
                                    type=self.type,
                                    message='choice',
                                    substitution=substitution)

        choosen_option = knowledge_base[defaults[0].option]

        self.choice = writer.current_choice(choosen_option.type)

        if defaults[0].default:
            self.choice_alternatives = [(option.uid,
                                         writer.choice_variant(option.type))
                                        for option in options
                                        if option.uid != choosen_option.uid]
        else:
            self.choice_alternatives = ()