From 57e5e03dc3211e60809845fffb0d244035dd5b7f Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 20 Nov 2021 14:46:58 +0100 Subject: [PATCH] Cleans up Anticipation a bit --- Scripts/Abilities/Anticipation.as | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/Scripts/Abilities/Anticipation.as b/Scripts/Abilities/Anticipation.as index 00c1ce3..ec81682 100644 --- a/Scripts/Abilities/Anticipation.as +++ b/Scripts/Abilities/Anticipation.as @@ -10,34 +10,19 @@ namespace Gen7 { bool DoesOpponentHaveSuperEffectiveMove(Battle@ battle, Pokemon@ pokemon){ bool hasSuperEffectiveMove = false; auto typeLib = battle.Library.StaticLibrary.TypeLibrary; - for (uint64 i = 0; i < battle.Sides.Length; i++){ - if (hasSuperEffectiveMove){ - break; - } + for (uint64 i = 0; i < battle.Sides.Length && !hasSuperEffectiveMove; i++){ auto side = battle.Sides[i]; if (side is pokemon.BattleSide){ continue; } - for (uint64 j = 0; j < side.Pokemon.Length; j++){ - if (hasSuperEffectiveMove){ - break; - } + for (uint64 j = 0; j < side.Pokemon.Length && !hasSuperEffectiveMove; j++){ auto opponent = side.Pokemon[j]; - if (opponent is null){ + if (opponent is null || opponent.IsFainted){ continue; } - if (opponent.IsFainted){ - continue; - } - for (uint64 k = 0; k < opponent.Moves.Length; k++){ - if (hasSuperEffectiveMove){ - break; - } + for (uint64 k = 0; k < opponent.Moves.Length && !hasSuperEffectiveMove; k++){ auto move = opponent.Moves[k]; - if (move is null){ - continue; - } - if (typeLib.GetEffectiveness(move.MoveData.Type, pokemon) > 1){ + if (move !is null && typeLib.GetEffectiveness(move.MoveData.Type, pokemon) > 1){ hasSuperEffectiveMove = true; break; }