Esempio n. 1
0
    def _check_messages(self, quest_type, message):
        writer = Writer(type=quest_type, message=message, substitution={}, hero=self.hero)

        # print '--------'
        # print writer.journal_id()
        # print writer.diary_id()
        # print writer.action_id()

        self.assertTrue(writer.journal_id().upper() in LEXICON_KEY.index_name or
                        writer.diary_id().upper() in LEXICON_KEY.index_name or
                        writer.action_id().upper() in LEXICON_KEY.index_name)
Esempio n. 2
0
    def _check_messages(self, quest_type, message):
        writer = Writer(type=quest_type, message=message, substitution={}, hero=self.hero)

        # print '--------'
        # print writer.journal_id()
        # print writer.diary_id()
        # print writer.action_id()

        self.assertTrue(hasattr(LEXICON_KEY, writer.journal_id().upper()) or
                        hasattr(LEXICON_KEY, writer.diary_id().upper()) or
                        hasattr(LEXICON_KEY, writer.action_id().upper()))
Esempio n. 3
0
    def _bruteforce(self, knowledge_base, path, table, starts, processed,
                    powers):
        current_state = knowledge_base[path[-1]]

        if current_state.uid in processed:
            return

        if isinstance(current_state, facts.Start):
            starts.append((current_state.uid, current_state.type))

            writer = Writer(type=starts[-1][1],
                            message=None,
                            substitution={},
                            hero=self.hero)
            self.assertTrue(writer.name_id().upper() in LEXICON_KEY.index_name)

            for participant in knowledge_base.filter(facts.QuestParticipant):
                if knowledge_base[participant.start].type != starts[-1][1]:
                    continue

                self.assertTrue(
                    writer.actor_id(participant.role).upper() in
                    LEXICON_KEY.index_name)

        self._check_action_messages(starts[-1][1], current_state.actions)

        powers |= self._get_powers(starts[-1][0], current_state.actions)

        if isinstance(current_state, facts.Finish):
            starts.pop()

        if not table.get(current_state.uid):
            return

        for next_jump in table[current_state.uid]:

            self._check_action_messages(starts[-1][1], next_jump.start_actions)
            self._check_action_messages(starts[-1][1], next_jump.end_actions)

            powers |= self._get_powers(starts[-1][0], next_jump.start_actions)
            powers |= self._get_powers(starts[-1][0], next_jump.end_actions)

            if isinstance(next_jump, facts.Option):
                writer = Writer(type=starts[-1][1],
                                message='choice',
                                substitution={},
                                hero=self.hero)
                self.assertTrue(
                    writer.choice_variant_id(next_jump.type).upper() in
                    LEXICON_KEY.index_name)
                self.assertTrue(
                    writer.current_choice_id(next_jump.type).upper() in
                    LEXICON_KEY.index_name)

            path.append(next_jump.state_to)
            self._bruteforce(knowledge_base, path, table, list(starts),
                             processed, powers)
            path.pop()

        processed.add(current_state.uid)
Esempio n. 4
0
    def _check_messages(self, quest_type, message):
        writer = Writer(type=quest_type,
                        message=message,
                        substitution={},
                        hero=self.hero)

        # print '--------'
        # print writer.journal_id()
        # print writer.diary_id()
        # print writer.action_id()

        self.assertTrue(
            writer.journal_id().upper() in LEXICON_KEY.index_name
            or writer.diary_id().upper() in LEXICON_KEY.index_name
            or writer.action_id().upper() in LEXICON_KEY.index_name)
Esempio n. 5
0
    def _bruteforce(self, knowledge_base, path, table, starts, processed, powers):
        current_state = knowledge_base[path[-1]]

        if current_state.uid in processed:
            return

        if isinstance(current_state, facts.Start):
            starts.append((current_state.uid, current_state.type))

            writer = Writer(type=starts[-1][1], message=None, substitution={}, hero=self.hero)
            self.assertTrue(writer.name_id().upper() in LEXICON_KEY.index_name)

            for participant in knowledge_base.filter(facts.QuestParticipant):
                if knowledge_base[participant.start].type != starts[-1][1]:
                    continue

                self.assertTrue(writer.actor_id(participant.role).upper() in LEXICON_KEY.index_name)

        self._check_action_messages(starts[-1][1], current_state.actions)

        powers |= self._get_powers(starts[-1][0], current_state.actions)

        if isinstance(current_state, facts.Finish):
            starts.pop()

        if not table.get(current_state.uid):
            return

        for next_jump in table[current_state.uid]:

            self._check_action_messages(starts[-1][1], next_jump.start_actions)
            self._check_action_messages(starts[-1][1], next_jump.end_actions)

            powers |= self._get_powers(starts[-1][0], next_jump.start_actions)
            powers |= self._get_powers(starts[-1][0], next_jump.end_actions)

            if isinstance(next_jump, facts.Option):
                writer = Writer(type=starts[-1][1], message='choice', substitution={}, hero=self.hero)
                self.assertTrue(writer.choice_variant_id(next_jump.type).upper() in LEXICON_KEY.index_name)
                self.assertTrue(writer.current_choice_id(next_jump.type).upper() in LEXICON_KEY.index_name)

            path.append(next_jump.state_to)
            self._bruteforce(knowledge_base, path, table, list(starts), processed, powers )
            path.pop()

        processed.add(current_state.uid)