diff --git a/src/phases/attempt-run-phase.ts b/src/phases/attempt-run-phase.ts index 4cd6bcc2740..553c9899db9 100644 --- a/src/phases/attempt-run-phase.ts +++ b/src/phases/attempt-run-phase.ts @@ -14,6 +14,9 @@ export class AttemptRunPhase extends PokemonPhase { super(scene, fieldIndex); } + /** For testing purposes: this is to force the pokemon to fail and escape */ + public forceFailEscape = false; + start() { super.start(); @@ -28,7 +31,7 @@ export class AttemptRunPhase extends PokemonPhase { applyAbAttrs(RunSuccessAbAttr, playerPokemon, null, false, escapeChance); - if (playerPokemon.randSeedInt(100) < escapeChance.value) { + if (playerPokemon.randSeedInt(100) < escapeChance.value && !this.forceFailEscape) { this.scene.playSound("se/flee"); this.scene.queueMessage(i18next.t("battle:runAwaySuccess"), null, true, 500); diff --git a/src/test/abilities/speed_boost.test.ts b/src/test/abilities/speed_boost.test.ts index 72564e0db87..d801e68b3ca 100644 --- a/src/test/abilities/speed_boost.test.ts +++ b/src/test/abilities/speed_boost.test.ts @@ -5,6 +5,9 @@ import { Species } from "#enums/species"; import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; +import { CommandPhase } from "#app/phases/command-phase"; +import { Command } from "#app/ui/command-ui-handler"; +import { AttemptRunPhase } from "#app/phases/attempt-run-phase"; describe("Abilities - Speed Boost", () => { let phaserGame: Phaser.Game; @@ -96,6 +99,26 @@ describe("Abilities - Speed Boost", () => { const playerPokemon = game.scene.getPlayerPokemon()!; expect(playerPokemon.getStatStage(Stat.SPD)).toBe(0); + game.move.select(Moves.SPLASH); + await game.toNextTurn(); + expect(playerPokemon.getStatStage(Stat.SPD)).toBe(1); + }); + + it("should not trigger if pokemon fails to escape", + async () => { + game.override.enemySpecies(Species.REGIELEKI); + await game.classicMode.startBattle([ Species.SHUCKLE ]); + + const commandPhase = game.scene.getCurrentPhase() as CommandPhase; + commandPhase.handleCommand(Command.RUN, 0); + const runPhase = game.scene.getCurrentPhase() as AttemptRunPhase; + runPhase.forceFailEscape = true; + await game.phaseInterceptor.to(AttemptRunPhase); + await game.toNextTurn(); + + const playerPokemon = game.scene.getPlayerPokemon()!; + expect(playerPokemon.getStatStage(Stat.SPD)).toBe(0); + game.move.select(Moves.SPLASH); await game.toNextTurn(); expect(playerPokemon.getStatStage(Stat.SPD)).toBe(1);