namespace Gen7{ [Move effect=Assurance] class Assurance : PkmnScript { void OverrideDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint &inout damage) override { auto damageEvent = target.Battle.History.GetLastDamageOnTarget(target); if (damageEvent is null){ return; } if (damageEvent.TurnNumber == target.Battle.CurrentTurn){ damage *= 2; } }; } } #if TESTS [Test name="Assurance: damage without damage on the same turn"] void Assurance_DamageWithoutEvent(){ auto battle = CreateSimpleBattle(684, "charizard", "venusaur", 100); auto mon1 = battle.GetBattleSide(0).GetPokemon(0); auto mon2 = battle.GetBattleSide(1).GetPokemon(0); auto script = cast(CreateMoveScript("Assurance")); Require(script !is null); uint damage = 100; auto executingMove = CreateExecutingMove("Assurance", mon1, mon2); script.OverrideDamage(executingMove, mon2, 0x0, damage); RequireEquals(100, damage); } [Test name="Assurance: damage with damage on the same turn"] void Assurance_DamageWithEvent(){ auto battle = CreateSimpleBattle(684, "charizard", "venusaur", 100); auto mon1 = battle.GetBattleSide(0).GetPokemon(0); auto mon2 = battle.GetBattleSide(1).GetPokemon(0); mon2.Damage(10, DamageSource::AttackDamage); auto script = cast(CreateMoveScript("Assurance")); Require(script !is null); uint damage = 100; auto executingMove = CreateExecutingMove("Assurance", mon1, mon2); script.OverrideDamage(executingMove, mon2, 0x0, damage); RequireEquals(200, damage); } #endif