Ejemplo n.º 1
0
        public void AddImmunity_ShouldAddDamageTypeToList()
        {
            // Arrange
            var instance = new HitPoints(42);

            // Act
            instance.AddImmunity(DamageTypes.Fire);
            // Assert
            instance.Immunities.Should().HaveCount(1);
            instance.Immunities[0].Should().Be(DamageTypes.Fire);
        }
Ejemplo n.º 2
0
        public void DealDamages_ShouldDoNoDamage_WhenImmunity()
        {
            // Arrange
            var instance = new HitPoints(42);

            instance.AddImmunity(DamageTypes.Fire);
            var damages = new DealDamage[]
            {
                new DealDamage {
                    DamageType = DamageTypes.Fire, Hp = 5
                }
            };

            // Act
            instance.DealDamages(damages);
            // Assert
            instance.CurrentHp.Should().Be(42);
        }
Ejemplo n.º 3
0
        private void AddDamageModifiers(HitPoints hitPoints, IEnumerable <CreateDefense> defenses)
        {
            foreach (var defense in defenses)
            {
                switch (defense.Defense)
                {
                case DamageModifierTypes.Immunity:
                    hitPoints.AddImmunity(defense.Type);
                    break;

                case DamageModifierTypes.Resistance:
                    hitPoints.AddResistance(defense.Type);
                    break;

                case DamageModifierTypes.Vulnerability:
                    hitPoints.AddVulnerability(defense.Type);
                    break;
                }
            }
        }