namespace Gen7 { [Move effect=AuroraVeil] class AuroraVeil : PkmnScript { void OnSecondaryEffect(ExecutingMove@ move, Pokemon@ target, uint8 hit) override { if (target.Battle.GetWeatherName() != "hail"){ move.GetHitData(target, hit).Fail(); return; } auto effect = cast(target.BattleSide.AddVolatile("AuroraVeil")); if (move.User.HasHeldItem("light_clay")){ effect.SetTurns(8); } else{ effect.SetTurns(5); } } } } #if TESTS [Test name="AuroraVeil: Fails without hail"] void AuroraVeil_FailsWithoutHail(){ auto battle = CreateSimpleBattle(0, "charizard", "venusaur", 100); auto mon1 = battle.GetBattleSide(0).GetPokemon(0); auto script = cast(CreateMoveScript("AuroraVeil")); auto executingMove = CreateExecutingMove("aurora_veil", mon1, mon1); script.OnSecondaryEffect(executingMove, mon1, 0x0); Require(executingMove.GetHitData(mon1, 0x0).HasFailed); } [Test name="AuroraVeil: Works with hail"] void AuroraVeil_WorksWithHail(){ auto battle = CreateSimpleBattle(0, "charizard", "venusaur", 100); battle.SetWeather("hail"); auto mon1 = battle.GetBattleSide(0).GetPokemon(0); auto script = cast(CreateMoveScript("AuroraVeil")); auto executingMove = CreateExecutingMove("aurora_veil", mon1, mon1); script.OnSecondaryEffect(executingMove, mon1, 0x0); Require(!executingMove.GetHitData(mon1, 0x0).HasFailed); Require(battle.GetBattleSide(0).HasVolatile("AuroraVeil")); } [Test name="AuroraVeil: Sets to 5 turns by default"] void AuroraVeil_FiveTurnsByDefault(){ auto battle = CreateSimpleBattle(0, "charizard", "venusaur", 100); battle.SetWeather("hail"); auto mon1 = battle.GetBattleSide(0).GetPokemon(0); auto script = cast(CreateMoveScript("AuroraVeil")); auto executingMove = CreateExecutingMove("aurora_veil", mon1, mon1); script.OnSecondaryEffect(executingMove, mon1, 0x0); Require(!executingMove.GetHitData(mon1, 0x0).HasFailed); Require(battle.GetBattleSide(0).HasVolatile("AuroraVeil")); auto effect = cast(battle.GetBattleSide(0).GetVolatile("AuroraVeil")); RequireEquals(5, effect._turnsRemaining); } [Test name="AuroraVeil: Sets to 8 turns with light clay"] void AuroraVeil_EightTurnsWithLightClay(){ auto battle = CreateSimpleBattle(0, "charizard", "venusaur", 100); battle.SetWeather("hail"); auto mon1 = battle.GetBattleSide(0).GetPokemon(0); mon1.SetHeldItem("light_clay"); auto script = cast(CreateMoveScript("AuroraVeil")); auto executingMove = CreateExecutingMove("aurora_veil", mon1, mon1); script.OnSecondaryEffect(executingMove, mon1, 0x0); Require(!executingMove.GetHitData(mon1, 0x0).HasFailed); Require(battle.GetBattleSide(0).HasVolatile("AuroraVeil")); auto effect = cast(battle.GetBattleSide(0).GetVolatile("AuroraVeil")); RequireEquals(8, effect._turnsRemaining); } #endif