[Bug] Fix Lingering Arena Trap if Pokemon Switches Out (#4755)
* [P2 BUG] Fixed Lingering Arena Trap if Pokemon Switches Out (#3713) * added switchOutStatus for all relevant moves * Added Lingering Arena Trap Fix for Mystery Encounters * Removing Redundant switchOutStatus Sets * added automated test case to arena trap test * Update src/field/pokemon.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update src/test/abilities/arena_trap.test.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com>
This commit is contained in:
parent
5fc41dfd16
commit
d5146a57b9
|
@ -325,6 +325,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||||
if (!this.scene) {
|
if (!this.scene) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (this.switchOutStatus) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return this.scene.field.getIndex(this) > -1;
|
return this.scene.field.getIndex(this) > -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1583,7 +1586,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
const trappedByAbility = new Utils.BooleanHolder(false);
|
const trappedByAbility = new Utils.BooleanHolder(false);
|
||||||
const opposingField = this.isPlayer() ? this.scene.getEnemyField() : this.scene.getPlayerField();
|
/**
|
||||||
|
* Contains opposing Pokemon (Enemy/Player Pokemon) depending on perspective
|
||||||
|
* Afterwards, it filters out Pokemon that have been switched out of the field so trapped abilities/moves do not trigger
|
||||||
|
*/
|
||||||
|
const opposingFieldUnfiltered = this.isPlayer() ? this.scene.getEnemyField() : this.scene.getPlayerField();
|
||||||
|
const opposingField = opposingFieldUnfiltered.filter(enemyPkm => enemyPkm.switchOutStatus === false);
|
||||||
|
|
||||||
opposingField.forEach((opponent) =>
|
opposingField.forEach((opponent) =>
|
||||||
applyCheckTrappedAbAttrs(CheckTrappedAbAttr, opponent, trappedByAbility, this, trappedAbMessages, simulated)
|
applyCheckTrappedAbAttrs(CheckTrappedAbAttr, opponent, trappedByAbility, this, trappedAbMessages, simulated)
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
|
import { allAbilities } from "#app/data/ability";
|
||||||
import { Abilities } from "#enums/abilities";
|
import { Abilities } from "#enums/abilities";
|
||||||
import { Moves } from "#enums/moves";
|
import { Moves } from "#enums/moves";
|
||||||
import { Species } from "#enums/species";
|
import { Species } from "#enums/species";
|
||||||
import GameManager from "#test/utils/gameManager";
|
import GameManager from "#test/utils/gameManager";
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, it, expect } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, it, expect, vi } from "vitest";
|
||||||
|
|
||||||
describe("Abilities - Arena Trap", () => {
|
describe("Abilities - Arena Trap", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
|
@ -55,4 +56,39 @@ describe("Abilities - Arena Trap", () => {
|
||||||
|
|
||||||
expect(game.scene.getEnemyField().length).toBe(2);
|
expect(game.scene.getEnemyField().length).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This checks if the Player Pokemon is able to switch out/run away after the Enemy Pokemon with {@linkcode Abilities.ARENA_TRAP}
|
||||||
|
* is forcefully moved out of the field from moves such as Roar {@linkcode Moves.ROAR}
|
||||||
|
*
|
||||||
|
* Note: It should be able to switch out/run away
|
||||||
|
*/
|
||||||
|
it("should lift if pokemon with this ability leaves the field", async () => {
|
||||||
|
game.override
|
||||||
|
.battleType("double")
|
||||||
|
.enemyMoveset(Moves.SPLASH)
|
||||||
|
.moveset([ Moves.ROAR, Moves.SPLASH ])
|
||||||
|
.ability(Abilities.BALL_FETCH);
|
||||||
|
await game.classicMode.startBattle([ Species.MAGIKARP, Species.SUDOWOODO, Species.LUNATONE ]);
|
||||||
|
|
||||||
|
const [ enemy1, enemy2 ] = game.scene.getEnemyField();
|
||||||
|
const [ player1, player2 ] = game.scene.getPlayerField();
|
||||||
|
|
||||||
|
vi.spyOn(enemy1, "getAbility").mockReturnValue(allAbilities[Abilities.ARENA_TRAP]);
|
||||||
|
|
||||||
|
game.move.select(Moves.ROAR);
|
||||||
|
game.move.select(Moves.SPLASH, 1);
|
||||||
|
|
||||||
|
// This runs the fist command phase where the moves are selected
|
||||||
|
await game.toNextTurn();
|
||||||
|
// During the next command phase the player pokemons should not be trapped anymore
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
game.move.select(Moves.SPLASH, 1);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(player1.isTrapped()).toBe(false);
|
||||||
|
expect(player2.isTrapped()).toBe(false);
|
||||||
|
expect(enemy1.isOnField()).toBe(false);
|
||||||
|
expect(enemy2.isOnField()).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue