[Bug] Fix NG crash when ability is reactivated for a Pokemon off the field (#5478)
This commit is contained in:
parent
929392fe8b
commit
b298138157
|
@ -1433,7 +1433,7 @@ export class SuppressAbilitiesTag extends ArenaTag {
|
|||
}),
|
||||
);
|
||||
|
||||
for (const fieldPokemon of globalScene.getField()) {
|
||||
for (const fieldPokemon of globalScene.getField(true)) {
|
||||
if (fieldPokemon && fieldPokemon.id !== pokemon.id) {
|
||||
[true, false].forEach(passive => applyOnLoseAbAttrs(fieldPokemon, passive));
|
||||
}
|
||||
|
@ -1466,7 +1466,7 @@ export class SuppressAbilitiesTag extends ArenaTag {
|
|||
globalScene.queueMessage(i18next.t("arenaTag:neutralizingGasOnRemove"));
|
||||
}
|
||||
|
||||
for (const pokemon of globalScene.getField()) {
|
||||
for (const pokemon of globalScene.getField(true)) {
|
||||
// There is only one pokemon with this attr on the field on removal, so its abilities are already active
|
||||
if (pokemon && !pokemon.hasAbilityWithAttr(PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr, false)) {
|
||||
[true, false].forEach(passive => applyOnGainAbAttrs(pokemon, passive));
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { BattlerIndex } from "#app/battle";
|
||||
import { PostSummonWeatherChangeAbAttr } from "#app/data/ability";
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import { ArenaTagType } from "#enums/arena-tag-type";
|
||||
import { Moves } from "#enums/moves";
|
||||
|
@ -7,7 +8,7 @@ import { Species } from "#enums/species";
|
|||
import { Stat } from "#enums/stat";
|
||||
import GameManager from "#test/testUtils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
describe("Abilities - Neutralizing Gas", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
|
@ -155,4 +156,25 @@ describe("Abilities - Neutralizing Gas", () => {
|
|||
|
||||
expect(game.scene.arena.getTag(ArenaTagType.NEUTRALIZING_GAS)).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should not activate abilities of pokemon no longer on the field", async () => {
|
||||
game.override
|
||||
.battleType("single")
|
||||
.ability(Abilities.NEUTRALIZING_GAS)
|
||||
.enemyAbility(Abilities.DELTA_STREAM);
|
||||
await game.classicMode.startBattle([ Species.MAGIKARP ]);
|
||||
|
||||
const enemy = game.scene.getEnemyPokemon()!;
|
||||
const weatherChangeAttr = enemy.getAbilityAttrs(PostSummonWeatherChangeAbAttr, false)[0];
|
||||
vi.spyOn(weatherChangeAttr, "applyPostSummon");
|
||||
|
||||
expect(game.scene.arena.getTag(ArenaTagType.NEUTRALIZING_GAS)).toBeDefined();
|
||||
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.killPokemon(enemy);
|
||||
await game.killPokemon(game.scene.getPlayerPokemon()!);
|
||||
|
||||
expect(game.scene.arena.getTag(ArenaTagType.NEUTRALIZING_GAS)).toBeUndefined();
|
||||
expect(weatherChangeAttr.applyPostSummon).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue