Adds anticipation ability
This commit is contained in:
51
Scripts/Abilities/Anticipation.as
Normal file
51
Scripts/Abilities/Anticipation.as
Normal file
@@ -0,0 +1,51 @@
|
||||
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;
|
||||
for (uint64 i = 0; i < battle.Sides.Length; i++){
|
||||
if (hasSuperEffectiveMove){
|
||||
break;
|
||||
}
|
||||
auto side = battle.Sides[i];
|
||||
if (side is pokemon.BattleSide){
|
||||
continue;
|
||||
}
|
||||
for (uint64 j = 0; j < side.Pokemon.Length; j++){
|
||||
if (hasSuperEffectiveMove){
|
||||
break;
|
||||
}
|
||||
auto opponent = side.Pokemon[j];
|
||||
if (opponent is null){
|
||||
continue;
|
||||
}
|
||||
if (opponent.IsFainted){
|
||||
continue;
|
||||
}
|
||||
for (uint64 k = 0; k < opponent.Moves.Length; k++){
|
||||
if (hasSuperEffectiveMove){
|
||||
break;
|
||||
}
|
||||
auto move = opponent.Moves[k];
|
||||
if (move is null){
|
||||
continue;
|
||||
}
|
||||
if (typeLib.GetEffectiveness(move.MoveData.Type, pokemon) > 1){
|
||||
hasSuperEffectiveMove = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hasSuperEffectiveMove;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user