mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-21 14:59:26 +02:00
adding failed run away test case
This commit is contained in:
parent
4126896c12
commit
3cbe5e38e2
@ -14,6 +14,9 @@ export class AttemptRunPhase extends PokemonPhase {
|
|||||||
super(scene, fieldIndex);
|
super(scene, fieldIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** For testing purposes: this is to force the pokemon to fail and escape */
|
||||||
|
public forceFailEscape = false;
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
super.start();
|
super.start();
|
||||||
|
|
||||||
@ -28,7 +31,7 @@ export class AttemptRunPhase extends PokemonPhase {
|
|||||||
|
|
||||||
applyAbAttrs(RunSuccessAbAttr, playerPokemon, null, false, escapeChance);
|
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.playSound("se/flee");
|
||||||
this.scene.queueMessage(i18next.t("battle:runAwaySuccess"), null, true, 500);
|
this.scene.queueMessage(i18next.t("battle:runAwaySuccess"), null, true, 500);
|
||||||
|
|
||||||
|
@ -5,6 +5,9 @@ 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, expect, it } from "vitest";
|
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", () => {
|
describe("Abilities - Speed Boost", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
@ -96,6 +99,26 @@ describe("Abilities - Speed Boost", () => {
|
|||||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||||
expect(playerPokemon.getStatStage(Stat.SPD)).toBe(0);
|
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);
|
game.move.select(Moves.SPLASH);
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
expect(playerPokemon.getStatStage(Stat.SPD)).toBe(1);
|
expect(playerPokemon.getStatStage(Stat.SPD)).toBe(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user