Adds anticipation ability

This commit is contained in:
Deukhoofd 2021-11-20 11:00:48 +01:00
parent 7857f5c35a
commit f19c60c4c1
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
4 changed files with 55 additions and 0 deletions

View 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;
}
}
}

View File

@ -4,6 +4,7 @@ type BattleSide {
bool IsDefeated { get const; };
bool HasFled { get const; };
Battle@ Battle { get const; };
narray<Pokemon>@ Pokemon { get const; };
uint8 GetPokemonIndex(const Pokemon@ pokemon) const;
Pokemon@ GetPokemon(uint8 index) const;
ref@ AddVolatile(const constString &in name);

View File

@ -19,6 +19,8 @@ type Pokemon {
float Weight { get const; set; };
float Height { get const; set; };
const constString& ActiveAbility { get const; };
uint64 TypesLength { get const; };
uint8 GetType(uint64 index) const;
bool HasHeldItem(const constString &in name) const;
void SetHeldItem(const constString &in name);
void SetHeldItem(const Item@ item);

View File

@ -1,4 +1,5 @@
type TypeLibrary {
uint8 GetTypeId(const constString &in name) const;
float GetSingleEffectiveness(uint8 attacking, uint8 defensive) const;
float GetEffectiveness(uint8 attackingType, Pokemon@ defender) const;
}