public void should_only_apply_applicable_tags() { var dummyTagLink1 = new TagLink { SourceTag = "silver", DestinationTag = "werewolf", Weight = 1.0f }; var dummyTagLink2 = new TagLink { SourceTag = "silver", DestinationTag = "undead", Weight = 0.5f }; var dummyTagList = new List<TagLink>() { dummyTagLink1, dummyTagLink2 }; var dummyWeapon = new Weapon { Damage = 1.0f, Tags = { "silver" } }; var dummyTarget = new GameEntity(new List<string> { "werewolf" }); var dummyAttack = new Attack { Weapon = dummyWeapon, Target = dummyTarget }; var bonusDamageWeightEffect = new BonusDamageDependentEffect(dummyTagList); var expectedResult = 1.0f; var actualResult = bonusDamageWeightEffect.RunEffect(dummyAttack); Assert.That(actualResult, Is.EqualTo(expectedResult)); }
public void should_only_apply_applicable_tags() { var dummyTagLink1 = new TagLink { SourceTag = "magic", DestinationTag = "magic", Weight = -0.5f }; var dummyTagLink2 = new TagLink { SourceTag = "physical", DestinationTag = "stalwart", Weight = -0.3f }; var dummyTagList = new List<TagLink>() { dummyTagLink1, dummyTagLink2 }; var dummyWeapon = new Weapon { Damage = 1.0f, Tags = { "magic" } }; var dummyTarget = new GameEntity(new List<string> { "magic" }); var dummyAttack = new Attack { Weapon = dummyWeapon, Target = dummyTarget }; var resistancesLinkEffect = new ResistancesDependentEffect(dummyTagList); var expectedResult =-0.5f; var actualResult = resistancesLinkEffect.RunEffect(dummyAttack); Assert.That(actualResult, Is.EqualTo(expectedResult)); }
public void should_calculate_total_damage() { var mockBonusDamageEffect = Substitute.For<ICombatDependentEffect>(); mockBonusDamageEffect.RunEffect(Arg.Any<Attack>()).Returns(2.0f); // 200% situational damage bonus var mockResistanceEffect = Substitute.For<ICombatDependentEffect>(); mockResistanceEffect.RunEffect(Arg.Any<Attack>()).Returns(-1.0f); // 100% situational resistance var mockPassiveEffect = Substitute.For<ICombatPassiveEffect>(); mockPassiveEffect.RunEffect(Arg.Any<Weapon>()).Returns(0.5f); // 50% passive damage bonus var dummyWeapon = new Weapon { Damage = 1.0f }; var dummyTarget = new GameEntity(); var dummyAttack = new Attack { Weapon = dummyWeapon, Target = dummyTarget }; var damageCalculator = new DamageCalculator(new []{ mockBonusDamageEffect, mockResistanceEffect}, new []{ mockPassiveEffect }); var expectedResult = 2.5f; var actualResult = damageCalculator.CalculateAttackDamage(dummyAttack); Assert.That(actualResult, Is.EqualTo(expectedResult)); }