public void AddVulnerability_ShouldAddDamageTypeToList() { // Arrange var instance = new HitPoints(42); // Act instance.AddVulnerability(DamageTypes.Fire); // Assert instance.Vulnerabilities.Should().HaveCount(1); instance.Vulnerabilities[0].Should().Be(DamageTypes.Fire); }
public void DealDamages_ShouldDoDoubleDamage_WhenVulnerability() { // Arrange var instance = new HitPoints(42); instance.AddVulnerability(DamageTypes.Fire); var damages = new DealDamage[] { new DealDamage { DamageType = DamageTypes.Fire, Hp = 5 } }; // Act instance.DealDamages(damages); // Assert instance.CurrentHp.Should().Be(32); }
public void DealDamages_ShouldProcessResistanceThenVulnerability_WhenBoth() { // Arrange var instance = new HitPoints(42); instance.AddResistance(DamageTypes.Fire); instance.AddVulnerability(DamageTypes.Fire); var damages = new DealDamage[] { new DealDamage { DamageType = DamageTypes.Fire, Hp = 9 } }; // Act instance.DealDamages(damages); // Assert instance.CurrentHp.Should().Be(34); }
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; } } }