Exemplo n.º 1
0
    def test_setup_quest(self):
        quests_helpers.setup_quest(self.hero)

        self.assertEqual(self.action_quest.state,
                         self.action_quest.STATE.PROCESSING)
        self.assertTrue(self.hero.quests.has_quests)
        self.storage._test_save()
Exemplo n.º 2
0
    def test_use(self):
        self.action_quest = ActionQuestPrototype.create(hero=self.hero)
        quests_helpers.setup_quest(self.hero)

        self.assertTrue(self.hero.quests.has_quests)

        with mock.patch(
                'the_tale.game.quests.container.QuestsContainer.mark_updated'
        ) as mark_updated:
            with self.check_not_changed(lambda: self.hero.power):
                with self.check_not_changed(lambda: self.hero.level):
                    with self.check_not_changed(
                            lambda: self.hero.quests.current_quest.current_info
                            .power):
                        with self.check_delta(
                                lambda: self.hero.quests.current_quest.
                                current_info.power_bonus,
                                self.CARD.effect.modificator):
                            result, step, postsave_actions = self.CARD.effect.use(
                                **self.use_attributes(storage=self.storage,
                                                      hero=self.hero))
                            self.assertEqual(
                                (result, step, postsave_actions),
                                (ComplexChangeTask.RESULT.SUCCESSED,
                                 ComplexChangeTask.STEP.SUCCESS, ()))

        self.assertEqual(mark_updated.call_count, 1)
Exemplo n.º 3
0
    def test_use(self):
        self.action_quest = ActionQuestPrototype.create(hero=self.hero)
        quests_helpers.setup_quest(self.hero)

        self.assertTrue(self.hero.quests.has_quests)

        with mock.patch('the_tale.game.quests.container.QuestsContainer.mark_updated') as mark_updated:
            with self.check_not_changed(lambda: self.hero.power):
                with self.check_not_changed(lambda: self.hero.level):
                    with self.check_not_changed(lambda: self.hero.quests.current_quest.current_info.power):
                        with self.check_delta(lambda: self.hero.quests.current_quest.current_info.power_bonus, self.CARD.POWER):
                            result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
                            self.assertEqual((result, step, postsave_actions), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ()))

        self.assertEqual(mark_updated.call_count, 1)
Exemplo n.º 4
0
    def test_use(self):
        self.action_quest = ActionQuestPrototype.create(hero=self.hero)
        quests_helpers.setup_quest(self.hero)

        self.assertTrue(self.hero.quests.has_quests)

        old_ui_experience = self.hero.quests.current_quest.current_info.ui_info(
            self.hero)['experience']

        with mock.patch(
                'the_tale.game.quests.container.QuestsContainer.mark_updated'
        ) as mark_updated:
            with self.check_not_changed(lambda: self.hero.experience):
                with self.check_not_changed(lambda: self.hero.level):
                    with self.check_not_changed(
                            lambda: self.hero.quests.current_quest.current_info
                            .experience):
                        with self.check_delta(
                                lambda: self.hero.quests.current_quest.
                                current_info.experience_bonus,
                                self.CARD.EXPERIENCE):
                            result, step, postsave_actions = self.card.use(
                                **self.use_attributes(storage=self.storage,
                                                      hero=self.hero))
                            self.assertEqual(
                                (result, step, postsave_actions),
                                (ComplexChangeTask.RESULT.SUCCESSED,
                                 ComplexChangeTask.STEP.SUCCESS, ()))

        self.assertEqual(mark_updated.call_count, 1)

        while self.hero.quests.has_quests:
            self.assertEqual(
                self.hero.quests.current_quest.quests_stack[0].
                experience_bonus, self.CARD.EXPERIENCE)
            self.assertEqual(
                self.hero.quests.current_quest.quests_stack[0].ui_info(
                    self.hero)['experience'],
                old_ui_experience + self.CARD.EXPERIENCE)
            self.storage.process_turn()
Exemplo n.º 5
0
    def test_use(self):
        self.action_quest = ActionQuestPrototype.create(hero=self.hero)
        quests_helpers.setup_quest(self.hero)

        self.assertTrue(self.hero.quests.has_quests)

        old_ui_experience = self.hero.quests.current_quest.current_info.ui_info(self.hero)['experience']

        with mock.patch('the_tale.game.quests.container.QuestsContainer.mark_updated') as mark_updated:
            with self.check_not_changed(lambda: self.hero.experience):
                with self.check_not_changed(lambda: self.hero.level):
                    with self.check_not_changed(lambda: self.hero.quests.current_quest.current_info.experience):
                        with self.check_delta(lambda: self.hero.quests.current_quest.current_info.experience_bonus, self.CARD.EXPERIENCE):
                            result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
                            self.assertEqual((result, step, postsave_actions), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ()))

        self.assertEqual(mark_updated.call_count, 1)

        while self.hero.quests.has_quests:
            self.assertEqual(self.hero.quests.current_quest.quests_stack[0].experience_bonus, self.CARD.EXPERIENCE)
            self.assertEqual(self.hero.quests.current_quest.quests_stack[0].ui_info(self.hero)['experience'], old_ui_experience + self.CARD.EXPERIENCE)
            self.storage.process_turn()
Exemplo n.º 6
0
    def test_step_with_no_quest(self):
        quests_helpers.setup_quest(self.hero)

        self.hero.quests.pop_quest()
        self.storage.process_turn()
        self.assertEqual(self.action_idl.leader, True)
Exemplo n.º 7
0
    def test_step_with_no_quest(self):
        quests_helpers.setup_quest(self.hero)

        self.hero.quests.pop_quest()
        self.storage.process_turn()
        self.assertEqual(self.action_idl.leader, True)
Exemplo n.º 8
0
    def test_setup_quest(self):
        quests_helpers.setup_quest(self.hero)

        self.assertEqual(self.action_quest.state, self.action_quest.STATE.PROCESSING)
        self.assertTrue(self.hero.quests.has_quests)
        self.storage._test_save()