using PkmnLib.Dynamic.Models; using PkmnLib.Dynamic.ScriptHandling; using PkmnLib.Plugin.Gen7.Libraries; using PkmnLib.Static; using PkmnLib.Static.Moves; namespace PkmnLib.Plugin.Gen7.Tests; public class DamageCalculatorTests { /// /// Implements the following example from Bulbapedia: /// /// /// Imagine a level 75 Glaceon that does not suffer a burn and holds no item with an effective Attack stat of 123 /// uses Ice Fang (an Ice-type physical move with a power of 65) against a Garchomp with an effective Defense stat /// of 163 in Generation VI, and does not land a critical hit. Then, the move will receive STAB, because Glaceon's /// Ice type matches the move's: STAB = 1.5. Additionally, Garchomp is Dragon/Ground, and therefore has a double /// weakness to the move's Ice type: Type = 4. All other (non-random) modifiers will be 1. /// /// That means Ice Fang will do between 168 and 196 HP damage, depending on luck. /// [Test] public void BulbapediaExampleDamageTest() { var attacker = new Mock(); // Imagine a level 75 Glaceon attacker.Setup(x => x.Level).Returns(75); // with an effective Attack stat of 123 attacker.Setup(x => x.BoostedStats).Returns(new StatisticSet( 1, 123, 1, 1, 1, 1)); // We use 10 as the Ice type attacker.Setup(x => x.Types).Returns([new TypeIdentifier(10)]); var defender = new Mock(); // a Garchomp with an effective Defense stat of 163 defender.Setup(x => x.BoostedStats).Returns(new StatisticSet( 1, 1, 163, 1, 1, 1)); var useMove = new Mock(); // Ice Fang (an Ice-type physical move with a power of 65) useMove.Setup(x => x.Category).Returns(MoveCategory.Physical); var damageCalculator = new Gen7DamageCalculator(false); var executingMove = new Mock(); executingMove.Setup(x => x.UseMove).Returns(useMove.Object); executingMove.Setup(x => x.User).Returns(attacker.Object); executingMove.Setup(x => x.GetScripts()).Returns(new ScriptIterator([])); var hit = new Mock(); // Ice Fang (an Ice-type physical move with a power of 65) hit.Setup(x => x.BasePower).Returns(65); hit.Setup(x => x.Type).Returns(new TypeIdentifier(10)); // has a double weakness to the move's Ice type hit.Setup(x => x.Effectiveness).Returns(4.0f); var damage = damageCalculator.GetDamage(executingMove.Object, defender.Object, 0, hit.Object); // That means Ice Fang will do between 168 and 196 HP damage, depending on luck. // Note that we are testing deterministic damage, so we expect the maximum damage. Assert.That(damage, Is.EqualTo(196)); } }