Example #1
0
    def test_timed_effect_is_triggered(self):
        """
        Test that timed effect is triggered only after enough time
        has passed
        """
        effect_factory = EffectsFactory()
        effect_factory.add_effect(
                            'major heal',
                            {'type': Heal,
                            'duration': 12,
                            'frequency': 3,
                            'tick': 3,
                            'healing': 10})

        potion = (ItemBuilder()
                        .with_effect(
                            EffectHandleBuilder()
                                .with_trigger('on drink')
                                .with_effect('major heal')
                                .with_charges(2))
                        .build())

        action_factory = ActionFactory(model = mock(),
                                       factories = [DrinkFactory(effect_factory)])

        character = (CharacterBuilder()
                        .with_action_factory(action_factory)
                        .with_hit_points(1)
                        .with_max_hp(10)
                        .build())

        character.drink(potion)

        assert_that(character, has_effects(1))
Example #2
0
    def test_effects_do_not_stack(self):
        """
        Test that single type of effect will not added twice
        """
        self.attacker.perform_attack(1)
        self.attacker.perform_attack(1)

        assert_that(self.defender, has_effects(1))
    def test_effects_do_not_stack(self):
        """
        Test that single type of effect will not added twice
        """
        rng = mock()
        when(rng).randint(1, 6).thenReturn(1)

        pyherc.vtable['\ufdd0:attack'](self.attacker,
                                       1)
        pyherc.vtable['\ufdd0:attack'](self.attacker,
                                       1)

        assert_that(self.defender, has_effects(1))
    def test_drinking_triggers_effect(self):
        """
        Test that timed effect is triggered only after enough time
        has passed
        """
        effect_factory = get_effect_creator({'major heal':
                                                {'type': Heal,
                                                 'duration': 12,
                                                 'frequency': 3,
                                                 'tick': 3,
                                                 'healing': 10,
                                                 'icon': 100,
                                                 'title': 'healig',
                                                 'description': 'healing'}})

        pyherc.vtable['\ufdd0:create-effect'] = effect_factory
        
        potion = (ItemBuilder()
                  .with_effect_handle(EffectHandleBuilder()
                               .with_trigger('on drink')
                               .with_effect('major heal')
                               .with_charges(2))
                  .build())

        set_action_factory(ActionFactoryBuilder()
                           .with_drink_factory(DrinkFactoryBuilder()
                                               .with_effect_factory(effect_factory))  # noqa
                           .build())

        character = (CharacterBuilder()
                     .with_hit_points(1)
                     .with_max_hp(10)
                     .build())

        drink(character,
              potion)

        assert_that(character, has_effects(1))