pokerogue/test/abilities/quick_draw.test.ts
Bertie690 061c987265
[Test] Convert game.override calls into chained line where possible
https://github.com/pagefaultgames/pokerogue/pull/5926

* Condensed all overrides into 1 line where possible

I hope I got them all...

* Fixed tests 0.5

* Cleaned up safeguard test to not use outdated code; fixed rest of errors

* Fixed illusion test

* Revert safeguart etst

* Fixed battle tets

* Fixed stuff

* Fixed things2.0

* Fixed import issues

* Revert changes outside of the tests directory

* Revert changes outside of the tests directory

---------

Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com>
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-06-15 00:40:41 -07:00

102 lines
2.8 KiB
TypeScript

import { allAbilities } from "#app/data/data-lists";
import { FaintPhase } from "#app/phases/faint-phase";
import { AbilityId } from "#enums/ability-id";
import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id";
import GameManager from "#test/testUtils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
describe("Abilities - Quick Draw", () => {
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
.battleStyle("single")
.starterSpecies(SpeciesId.MAGIKARP)
.ability(AbilityId.QUICK_DRAW)
.moveset([MoveId.TACKLE, MoveId.TAIL_WHIP])
.enemyLevel(100)
.enemySpecies(SpeciesId.MAGIKARP)
.enemyAbility(AbilityId.BALL_FETCH)
.enemyMoveset([MoveId.TACKLE]);
vi.spyOn(
allAbilities[AbilityId.QUICK_DRAW].getAttrs("BypassSpeedChanceAbAttr")[0],
"chance",
"get",
).mockReturnValue(100);
});
test("makes pokemon going first in its priority bracket", async () => {
await game.classicMode.startBattle();
const pokemon = game.scene.getPlayerPokemon()!;
const enemy = game.scene.getEnemyPokemon()!;
pokemon.hp = 1;
enemy.hp = 1;
game.move.select(MoveId.TACKLE);
await game.phaseInterceptor.to(FaintPhase, false);
expect(pokemon.isFainted()).toBe(false);
expect(enemy.isFainted()).toBe(true);
expect(pokemon.waveData.abilitiesApplied).contain(AbilityId.QUICK_DRAW);
}, 20000);
test(
"does not triggered by non damage moves",
{
retry: 5,
},
async () => {
await game.classicMode.startBattle();
const pokemon = game.scene.getPlayerPokemon()!;
const enemy = game.scene.getEnemyPokemon()!;
pokemon.hp = 1;
enemy.hp = 1;
game.move.select(MoveId.TAIL_WHIP);
await game.phaseInterceptor.to(FaintPhase, false);
expect(pokemon.isFainted()).toBe(true);
expect(enemy.isFainted()).toBe(false);
expect(pokemon.waveData.abilitiesApplied).not.contain(AbilityId.QUICK_DRAW);
},
);
test("does not increase priority", async () => {
game.override.enemyMoveset([MoveId.EXTREME_SPEED]);
await game.classicMode.startBattle();
const pokemon = game.scene.getPlayerPokemon()!;
const enemy = game.scene.getEnemyPokemon()!;
pokemon.hp = 1;
enemy.hp = 1;
game.move.select(MoveId.TACKLE);
await game.phaseInterceptor.to(FaintPhase, false);
expect(pokemon.isFainted()).toBe(true);
expect(enemy.isFainted()).toBe(false);
expect(pokemon.waveData.abilitiesApplied).contain(AbilityId.QUICK_DRAW);
}, 20000);
});