mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-21 07:42:25 +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 {
|
override applyPreAttack(pokemon: Pokemon, passive: boolean, simulated: boolean, defender: Pokemon, move: Move, args: any[]): void {
|
||||||
const hitCount = args[0] as Utils.NumberHolder;
|
const hitCount = args[0] as Utils.NumberHolder;
|
||||||
const multiplier = args[1] as Utils.NumberHolder;
|
const multiplier = args[1] as Utils.NumberHolder;
|
||||||
this.showAbility = !!hitCount?.value;
|
|
||||||
if (hitCount?.value) {
|
if (hitCount?.value) {
|
||||||
hitCount.value += 1;
|
hitCount.value += 1;
|
||||||
}
|
}
|
||||||
|
@ -7,19 +7,30 @@ export class ShowAbilityPhase extends PokemonPhase {
|
|||||||
private passive: boolean;
|
private passive: boolean;
|
||||||
private pokemonName: string;
|
private pokemonName: string;
|
||||||
private abilityName: string;
|
private abilityName: string;
|
||||||
|
private pokemonOnField: boolean;
|
||||||
|
|
||||||
constructor(battlerIndex: BattlerIndex, passive: boolean = false) {
|
constructor(battlerIndex: BattlerIndex, passive: boolean = false) {
|
||||||
super(battlerIndex);
|
super(battlerIndex);
|
||||||
|
|
||||||
this.passive = passive;
|
this.passive = passive;
|
||||||
// Set these now as the pokemon object may change before the queued phase is run
|
|
||||||
this.pokemonName = getPokemonNameWithAffix(this.getPokemon());
|
const pokemon = this.getPokemon();
|
||||||
this.abilityName = (passive ? this.getPokemon().getPassiveAbility() : this.getPokemon().getAbility()).name;
|
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() {
|
start() {
|
||||||
super.start();
|
super.start();
|
||||||
|
|
||||||
|
if (!this.pokemonOnField) {
|
||||||
|
return this.end();
|
||||||
|
}
|
||||||
const pokemon = this.getPokemon();
|
const pokemon = this.getPokemon();
|
||||||
|
|
||||||
if (pokemon) {
|
if (pokemon) {
|
||||||
|
Loading…
Reference in New Issue
Block a user