Gen7Data/Scripts/Abilities/Anticipation.as

36 lines
1.4 KiB
ActionScript
Raw Normal View History

2021-11-20 10:00:48 +00:00
namespace Gen7 {
[Ability effect=Anticipation]
class Anticipation : PkmnScript {
void OnSwitchIn(Pokemon@ pokemon){
if (DoesOpponentHaveSuperEffectiveMove(pokemon.Battle, pokemon)){
// TODO: Shudder
}
}
bool DoesOpponentHaveSuperEffectiveMove(Battle@ battle, Pokemon@ pokemon){
bool hasSuperEffectiveMove = false;
auto typeLib = battle.Library.StaticLibrary.TypeLibrary;
2021-11-20 13:46:58 +00:00
for (uint64 i = 0; i < battle.Sides.Length && !hasSuperEffectiveMove; i++){
2021-11-20 10:00:48 +00:00
auto side = battle.Sides[i];
if (side is pokemon.BattleSide){
continue;
}
2021-11-20 13:46:58 +00:00
for (uint64 j = 0; j < side.Pokemon.Length && !hasSuperEffectiveMove; j++){
2021-11-20 10:00:48 +00:00
auto opponent = side.Pokemon[j];
2021-11-20 13:46:58 +00:00
if (opponent is null || opponent.IsFainted){
2021-11-20 10:00:48 +00:00
continue;
}
2021-11-20 13:46:58 +00:00
for (uint64 k = 0; k < opponent.Moves.Length && !hasSuperEffectiveMove; k++){
2021-11-20 10:00:48 +00:00
auto move = opponent.Moves[k];
2021-11-20 13:46:58 +00:00
if (move !is null && typeLib.GetEffectiveness(move.MoveData.Type, pokemon) > 1){
2021-11-20 10:00:48 +00:00
hasSuperEffectiveMove = true;
break;
}
}
}
}
return hasSuperEffectiveMove;
}
}
}