pokerogue/test/moves/payback.test.ts
Bertie690 12fbff71d2
[Test] Added tests for Intimidate, Fishious Rend/Bolt Beak, Payback and Moongeist Beam & co. (#5858)
* Added additional tests for intimidate & ability-ignoring moves

* Added a few basic tests for Fishious Rend and Bolt Beak

* Fixed comment

* Fixe test and added commetn

* Update first-attack-double-power.test.ts

* Fixed incorrect ignore-abilities.test.ts test suite description

* Update ignore-abilities.test.ts suite name

* Fix first-attack-double-power.test.ts

* Actually fixed import

* Update intimidate.test.ts

* Fix test imprts

* Added guard dog tests

* Fixed tests

* Renamed test file

* Added Payback tests

* Fixed accidental unusde class

* Fixed tests

* Fixed flaky test due to 1 length trainer thing

* dd

---------

Co-authored-by: Wlowscha <54003515+Wlowscha@users.noreply.github.com>
2025-07-13 05:55:05 +00:00

70 lines
2.3 KiB
TypeScript

import { allMoves } from "#app/data/data-lists";
import { AbilityId } from "#enums/ability-id";
import { BattlerIndex } from "#enums/battler-index";
import { MoveId } from "#enums/move-id";
import { PokeballType } from "#enums/pokeball";
import { SpeciesId } from "#enums/species-id";
import GameManager from "#test/testUtils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi, type MockInstance } from "vitest";
describe("Move - Payback", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
let powerSpy: MockInstance;
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)
.enemyLevel(100)
.enemySpecies(SpeciesId.DRACOVISH)
.enemyAbility(AbilityId.BALL_FETCH)
.enemyMoveset(MoveId.SPLASH)
.startingModifier([{ name: "POKEBALL", count: 5 }]);
powerSpy = vi.spyOn(allMoves[MoveId.PAYBACK], "calculateBattlePower");
});
it("should double power if the user moves after the target", async () => {
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
// turn 1: enemy, then player (boost)
game.move.use(MoveId.PAYBACK);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.toNextTurn();
expect(powerSpy).toHaveLastReturnedWith(allMoves[MoveId.PAYBACK].power * 2);
// turn 2: player, then enemy (no boost)
game.move.use(MoveId.PAYBACK);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.toEndOfTurn();
expect(powerSpy).toHaveLastReturnedWith(allMoves[MoveId.PAYBACK].power);
});
// TODO: Enable test once ability to force catch failure is added
it.todo("should trigger for enemies on player failed ball catch", async () => {
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
game.doThrowPokeball(PokeballType.POKEBALL);
await game.move.forceEnemyMove(MoveId.PAYBACK);
await game.toEndOfTurn();
expect(powerSpy).toHaveLastReturnedWith(allMoves[MoveId.PAYBACK].power * 2);
});
});