mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-26 08:46:55 +00:00
[Test] Optimize Quick Draw tests (#2625)
* optimize the tests * add level override in favor of directly changing stats
This commit is contained in:
parent
f3eeb6abea
commit
576f099243
@ -1,16 +1,13 @@
|
|||||||
import {afterEach, beforeAll, beforeEach, describe, expect, it, vi} from "vitest";
|
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import GameManager from "#app/test/utils/gameManager";
|
import GameManager from "#app/test/utils/gameManager";
|
||||||
import * as overrides from "#app/overrides";
|
import * as Overrides from "#app/overrides";
|
||||||
import { Abilities } from "#enums/abilities";
|
import { Abilities } from "#enums/abilities";
|
||||||
import { Species } from "#enums/species";
|
import { Species } from "#enums/species";
|
||||||
import {EnemyCommandPhase, TitlePhase, TurnEndPhase, TurnStartPhase,
|
import { FaintPhase } from "#app/phases";
|
||||||
} from "#app/phases";
|
|
||||||
import { Moves } from "#enums/moves";
|
import { Moves } from "#enums/moves";
|
||||||
import { Stat } from "#app/data/pokemon-stat";
|
|
||||||
import { getMovePosition } from "#app/test/utils/gameManagerUtils";
|
import { getMovePosition } from "#app/test/utils/gameManagerUtils";
|
||||||
import { allAbilities, BypassSpeedChanceAbAttr } from "#app/data/ability";
|
import { allAbilities, BypassSpeedChanceAbAttr } from "#app/data/ability";
|
||||||
|
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
describe("Abilities - Quick Draw", () => {
|
describe("Abilities - Quick Draw", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
@ -28,90 +25,66 @@ describe("Abilities - Quick Draw", () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
game = new GameManager(phaserGame);
|
game = new GameManager(phaserGame);
|
||||||
vi.spyOn(overrides, "SINGLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
|
vi.spyOn(Overrides, "SINGLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
|
||||||
vi.spyOn(overrides, "ABILITY_OVERRIDE", "get").mockReturnValue(
|
vi.spyOn(Overrides, "ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.QUICK_DRAW);
|
||||||
Abilities.QUICK_DRAW
|
vi.spyOn(Overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.TACKLE, Moves.TAIL_WHIP]);
|
||||||
);
|
vi.spyOn(Overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(100);
|
||||||
vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(
|
vi.spyOn(Overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.RATTATA);
|
||||||
Species.RATTATA
|
vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
|
||||||
);
|
|
||||||
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([
|
|
||||||
Moves.TACKLE,
|
|
||||||
Moves.TACKLE,
|
|
||||||
Moves.TACKLE,
|
|
||||||
Moves.TACKLE,
|
|
||||||
]);
|
|
||||||
|
|
||||||
vi.spyOn(
|
vi.spyOn(allAbilities[Abilities.QUICK_DRAW].getAttrs(BypassSpeedChanceAbAttr)[0], "chance", "get").mockReturnValue(100);
|
||||||
allAbilities[Abilities.QUICK_DRAW].getAttrs(BypassSpeedChanceAbAttr)[0],
|
|
||||||
"chance","get"
|
|
||||||
).mockReturnValue(100);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("makes pokemon going first in its priority bracket", async() => {
|
test("makes pokemon going first in its priority bracket", async () => {
|
||||||
await game.startBattle([Species.SLOWBRO]);
|
await game.startBattle([Species.SLOWBRO]);
|
||||||
|
|
||||||
const pokemon = game.scene.getParty()[0];
|
const pokemon = game.scene.getPlayerPokemon();
|
||||||
const enemy = game.scene.getEnemyParty()[0];
|
const enemy = game.scene.getEnemyPokemon();
|
||||||
|
|
||||||
pokemon.stats[Stat.SPD] = 50;
|
|
||||||
enemy.stats[Stat.SPD] = 150;
|
|
||||||
pokemon.hp = 1;
|
pokemon.hp = 1;
|
||||||
enemy.hp = 1;
|
enemy.hp = 1;
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
|
||||||
|
await game.phaseInterceptor.to(FaintPhase, false);
|
||||||
|
|
||||||
await game.phaseInterceptor.run(EnemyCommandPhase);
|
expect(pokemon.isFainted()).toBe(false);
|
||||||
await game.phaseInterceptor.run(TurnStartPhase);
|
expect(enemy.isFainted()).toBe(true);
|
||||||
await game.phaseInterceptor.to(TurnEndPhase);
|
expect(pokemon.battleData.abilitiesApplied).contain(Abilities.QUICK_DRAW);
|
||||||
|
|
||||||
expect(pokemon.battleData.abilityRevealed).toBe(true);
|
|
||||||
}, 20000);
|
}, 20000);
|
||||||
|
|
||||||
it("does not triggered by non damage moves", async () => {
|
test("does not triggered by non damage moves", async () => {
|
||||||
await game.startBattle([Species.SLOWBRO]);
|
await game.startBattle([Species.SLOWBRO]);
|
||||||
|
|
||||||
const pokemon = game.scene.getParty()[0];
|
const pokemon = game.scene.getPlayerPokemon();
|
||||||
const enemy = game.scene.getEnemyParty()[0];
|
const enemy = game.scene.getEnemyPokemon();
|
||||||
|
|
||||||
pokemon.stats[Stat.SPD] = 50;
|
|
||||||
enemy.stats[Stat.SPD] = 150;
|
|
||||||
pokemon.hp = 1;
|
pokemon.hp = 1;
|
||||||
enemy.hp = 1;
|
enemy.hp = 1;
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.TOXIC));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.TAIL_WHIP));
|
||||||
|
await game.phaseInterceptor.to(FaintPhase, false);
|
||||||
|
|
||||||
await game.phaseInterceptor.run(EnemyCommandPhase);
|
expect(pokemon.isFainted()).toBe(true);
|
||||||
await game.phaseInterceptor.run(TurnStartPhase);
|
expect(enemy.isFainted()).toBe(false);
|
||||||
await game.phaseInterceptor.to(TitlePhase);
|
expect(pokemon.battleData.abilitiesApplied).not.contain(Abilities.QUICK_DRAW);
|
||||||
|
|
||||||
expect(pokemon.battleData.abilityRevealed).not.toBe(true);
|
|
||||||
}, 20000);
|
}, 20000);
|
||||||
|
|
||||||
it("does not increase priority", async () => {
|
test("does not increase priority", async () => {
|
||||||
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([
|
vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue(Array(4).fill(Moves.EXTREME_SPEED));
|
||||||
Moves.EXTREME_SPEED,
|
|
||||||
Moves.EXTREME_SPEED,
|
|
||||||
Moves.EXTREME_SPEED,
|
|
||||||
Moves.EXTREME_SPEED,
|
|
||||||
]);
|
|
||||||
|
|
||||||
await game.startBattle([Species.SLOWBRO]);
|
await game.startBattle([Species.SLOWBRO]);
|
||||||
|
|
||||||
const pokemon = game.scene.getParty()[0];
|
const pokemon = game.scene.getPlayerPokemon();
|
||||||
const enemy = game.scene.getEnemyParty()[0];
|
const enemy = game.scene.getEnemyPokemon();
|
||||||
|
|
||||||
pokemon.stats[Stat.SPD] = 50;
|
|
||||||
enemy.stats[Stat.SPD] = 150;
|
|
||||||
pokemon.hp = 1;
|
pokemon.hp = 1;
|
||||||
enemy.hp = 1;
|
enemy.hp = 1;
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
|
||||||
|
await game.phaseInterceptor.to(FaintPhase, false);
|
||||||
|
|
||||||
await game.phaseInterceptor.run(EnemyCommandPhase);
|
expect(pokemon.isFainted()).toBe(true);
|
||||||
await game.phaseInterceptor.run(TurnStartPhase);
|
expect(enemy.isFainted()).toBe(false);
|
||||||
await game.phaseInterceptor.to(TitlePhase);
|
expect(pokemon.battleData.abilitiesApplied).contain(Abilities.QUICK_DRAW);
|
||||||
|
|
||||||
expect(pokemon.battleData.abilityRevealed).toBe(true);
|
|
||||||
}, 20000);
|
}, 20000);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user