コード例 #1
0
    def test_triggering_damage_raises_event(self):
        """
        Triggering damage effect should raise a proper event
        """
        model = mock()
        target = (CharacterBuilder().with_model(model).build())

        effect = (DamageBuilder().with_target(target).build())

        effect.trigger()

        verify(model).raise_event(event_type_of('damage triggered'))
コード例 #2
0
    def test_damage_effect(self):
        """
        Test that a damage effect can be applied on a character
        """
        character = (
            CharacterBuilder().with_hit_points(15).with_max_hp(15).build())

        effect = (DamageBuilder().with_duration(0).with_frequency(0).with_tick(
            0).with_damage(10).with_target(character).build())

        effect.trigger()

        assert_that(character.hit_points, is_(equal_to(5)))
コード例 #3
0
    def test_triggering_damage_respects_damage_modifier(self):
        """
        Damage modifier should be respected
        """
        model = mock()

        target = (CharacterBuilder().with_model(model).with_hit_points(
            10).with_effect(
                DamageModifier(modifier=-5,
                               damage_type='magical',
                               duration=0,
                               frequency=0,
                               tick=0,
                               icon=0,
                               title='resistance',
                               description='resistance')).build())

        effect = (DamageBuilder().with_target(target).with_damage(5).build())

        effect.trigger()

        assert_that(target.hit_points, is_(equal_to(10)))