From 2e3a7d47e0a5f17c303fd762c7740a589e8fac17 Mon Sep 17 00:00:00 2001 From: Acelynn Zhang <102631387+acelynnzhang@users.noreply.github.com> Date: Fri, 25 Jul 2025 19:55:13 -0400 Subject: [PATCH] [Bug] Fix Thrash continuing on caught Pokemon (#6144) Fix Thrash continuing on caught Pokemon --- src/phases/attempt-capture-phase.ts | 1 + test/phases/capture-phase.test.ts | 37 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 test/phases/capture-phase.test.ts diff --git a/src/phases/attempt-capture-phase.ts b/src/phases/attempt-capture-phase.ts index 604d4fd8384..fcddd23dd20 100644 --- a/src/phases/attempt-capture-phase.ts +++ b/src/phases/attempt-capture-phase.ts @@ -279,6 +279,7 @@ export class AttemptCapturePhase extends PokemonPhase { globalScene.updateModifiers(true); removePokemon(); if (newPokemon) { + newPokemon.leaveField(true, true, false); newPokemon.loadAssets().then(end); } else { end(); diff --git a/test/phases/capture-phase.test.ts b/test/phases/capture-phase.test.ts new file mode 100644 index 00000000000..45a915ebb55 --- /dev/null +++ b/test/phases/capture-phase.test.ts @@ -0,0 +1,37 @@ +import { AbilityId } from "#enums/ability-id"; +import { MoveId } from "#enums/move-id"; +import { SpeciesId } from "#enums/species-id"; +import { GameManager } from "#test/test-utils/game-manager"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, it } from "vitest"; + +describe("Capture Phase", () => { + let phaserGame: Phaser.Game; + let game: GameManager; + + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, + }); + }); + + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + game.override + .ability(AbilityId.BALL_FETCH) + .battleStyle("single") + .criticalHits(false) + .enemySpecies(SpeciesId.MAGIKARP) + .enemyAbility(AbilityId.BALL_FETCH) + .enemyMoveset(MoveId.SPLASH) + .startingLevel(100) + .enemyLevel(100); + }); + + // TODO: write test and enable once the phase's logic has been refactored + it.todo("should reset the captured Pokemon's temporary data"); +});