mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-21 15:52:18 +02:00
Prevent crashes in case an ability for a pokemon not on the field is shown
This commit is contained in:
parent
e5f5f1bd9a
commit
f5468f8d58
@ -1408,7 +1408,6 @@ export class AddSecondStrikeAbAttr extends PreAttackAbAttr {
|
||||
override applyPreAttack(pokemon: Pokemon, passive: boolean, simulated: boolean, defender: Pokemon, move: Move, args: any[]): void {
|
||||
const hitCount = args[0] as Utils.NumberHolder;
|
||||
const multiplier = args[1] as Utils.NumberHolder;
|
||||
this.showAbility = !!hitCount?.value;
|
||||
if (hitCount?.value) {
|
||||
hitCount.value += 1;
|
||||
}
|
||||
|
@ -7,19 +7,30 @@ export class ShowAbilityPhase extends PokemonPhase {
|
||||
private passive: boolean;
|
||||
private pokemonName: string;
|
||||
private abilityName: string;
|
||||
private pokemonOnField: boolean;
|
||||
|
||||
constructor(battlerIndex: BattlerIndex, passive: boolean = false) {
|
||||
super(battlerIndex);
|
||||
|
||||
this.passive = passive;
|
||||
// Set these now as the pokemon object may change before the queued phase is run
|
||||
this.pokemonName = getPokemonNameWithAffix(this.getPokemon());
|
||||
this.abilityName = (passive ? this.getPokemon().getPassiveAbility() : this.getPokemon().getAbility()).name;
|
||||
|
||||
const pokemon = this.getPokemon();
|
||||
if (pokemon) {
|
||||
// Set these now as the pokemon object may change before the queued phase is run
|
||||
this.pokemonName = getPokemonNameWithAffix(pokemon);
|
||||
this.abilityName = (passive ? this.getPokemon().getPassiveAbility() : this.getPokemon().getAbility()).name;
|
||||
this.pokemonOnField = true;
|
||||
} else {
|
||||
this.pokemonOnField = false;
|
||||
}
|
||||
}
|
||||
|
||||
start() {
|
||||
super.start();
|
||||
|
||||
if (!this.pokemonOnField) {
|
||||
return this.end();
|
||||
}
|
||||
const pokemon = this.getPokemon();
|
||||
|
||||
if (pokemon) {
|
||||
|
Loading…
Reference in New Issue
Block a user