Fixed spite test

This commit is contained in:
Bertie690 2025-07-27 23:28:15 -04:00
parent 77f6e5b36e
commit a9e66e43ad
3 changed files with 15 additions and 23 deletions

View File

@ -41,6 +41,7 @@ declare module "vitest" {
* Matcher to check the contents of a {@linkcode Pokemon}'s move history.
*
* @param expectedValue - The expected value; can be a {@linkcode MoveId} or a partially filled {@linkcode TurnMove}
* containing the desired properties to check
* @param index - The index of the move history entry to check, in order from most recent to least recent.
* Default `0` (last used move)
* @see {@linkcode Pokemon.getLastXMoves}
@ -125,9 +126,9 @@ declare module "vitest" {
* @param expectedValue - The {@linkcode MoveId} of the {@linkcode PokemonMove} that should have consumed PP
* @param ppUsed - The amount of PP that should have been consumed
* @remarks
* If the Pokemon's moveset has been set via {@linkcode Overrides.MOVESET_OVERRIDE} or {@linkcode OPP_MOVESET_OVERRIDE},
* If the Pokemon's moveset has been set via {@linkcode Overrides.MOVESET_OVERRIDE}/{@linkcode Overrides.OPP_MOVESET_OVERRIDE}
* or contains the desired move more than once, this will fail the test.
*/
toHaveUsedPP(expectedMove: MoveId, ppUsed: number): void;
toHaveUsedPP(expectedMove: MoveId, ppUsed?: number): void;
}
}

View File

@ -1,6 +1,7 @@
import { AbilityId } from "#enums/ability-id";
import { BattlerIndex } from "#enums/battler-index";
import { MoveId } from "#enums/move-id";
import { MoveResult } from "#enums/move-result";
import { SpeciesId } from "#enums/species-id";
import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser";
@ -62,27 +63,21 @@ describe("Moves - Spite", () => {
game.move.use(MoveId.SPLASH);
await game.move.selectEnemyMove(MoveId.TACKLE);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.toEndOfTurn();
const feebas = game.field.getPlayerPokemon();
expect(feebas).toHaveUsedMove({});
expect(karp).toHaveUsedPP(MoveId.TACKLE, 1);
game.move.use(MoveId.SPITE);
await game.move.forceEnemyMove(MoveId.TACKLE);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.toEndOfTurn();
expect(karp).toHaveUsedPP(MoveId.TACKLE, 4 + 1);
const feebas = game.field.getPlayerPokemon();
expect(feebas).toHaveUsedMove({ move: MoveId.SPITE, result: MoveResult.FAIL });
expect(karp).toHaveUsedPP(MoveId.TACKLE, 1);
});
it("should ignore virtual or Dancer-induced moves", async () => {
it("should ignore virtual and Dancer-induced moves", async () => {
game.override.battleStyle("double").enemyAbility(AbilityId.DANCER);
game.move.forceMetronomeMove(MoveId.SPLASH);
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
const [karp1, karp2] = game.scene.getEnemyField();
game.move.changeMoveset(karp1, [MoveId.SPLASH, MoveId.METRONOME]);
game.move.changeMoveset(karp1, [MoveId.SPLASH, MoveId.METRONOME, MoveId.SWORDS_DANCE]);
game.move.changeMoveset(karp2, [MoveId.SWORDS_DANCE, MoveId.TACKLE]);
game.move.use(MoveId.SPITE);
@ -91,13 +86,9 @@ describe("Moves - Spite", () => {
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER]);
await game.toEndOfTurn();
expect(karp).toHaveUsedPP(MoveId.TACKLE, 1);
game.move.use(MoveId.SPITE);
await game.move.forceEnemyMove(MoveId.TACKLE);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.toEndOfTurn();
expect(karp).toHaveUsedPP(MoveId.TACKLE, 4 + 1);
// Spite ignored virtual splash and swords dance, instead only docking from metronome
expect(karp1).toHaveUsedPP(MoveId.SPLASH, 0);
expect(karp1).toHaveUsedPP(MoveId.SWORDS_DANCE, 0);
expect(karp1).toHaveUsedPP(MoveId.METRONOME, 5);
});
});

View File

@ -12,7 +12,7 @@ import type { MatcherState, SyncExpectationResult } from "@vitest/expect";
* Matcher to check the contents of a {@linkcode Pokemon}'s move history.
* @param received - The actual value received. Should be a {@linkcode Pokemon}
* @param expectedValue - The {@linkcode MoveId} the Pokemon is expected to have used,
* or a partially filled {@linkcode TurnMove} containing the desired properties to check.
* or a partially filled {@linkcode TurnMove} containing the desired properties to check
* @param index - The index of the move history entry to check, in order from most recent to least recent.
* Default `0` (last used move)
* @returns Whether the matcher passed