Fixed up tests

This commit is contained in:
Bertie690 2025-07-28 11:37:33 -04:00
parent 447bc59b40
commit 0a3e4f9615
3 changed files with 69 additions and 42 deletions

View File

@ -3461,6 +3461,7 @@ export class GrudgeTag extends BattlerTag {
* @param sourcePokemon {@linkcode Pokemon} the source of the move that fainted the tag's bearer
* @returns `false` if Grudge activates its effect or lapses
*/
// TODO: Confirm whether this should interact with copying moves
override lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType, sourcePokemon?: Pokemon): boolean {
if (lapseType === BattlerTagLapseType.CUSTOM && sourcePokemon) {
if (sourcePokemon.isActive() && pokemon.isOpponent(sourcePokemon)) {

View File

@ -2,6 +2,7 @@ import { AbilityId } from "#enums/ability-id";
import { BattlerIndex } from "#enums/battler-index";
import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id";
import { WeatherType } from "#enums/weather-type";
import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
@ -23,68 +24,61 @@ describe("Moves - Grudge", () => {
beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.moveset([MoveId.EMBER, MoveId.SPLASH])
.ability(AbilityId.BALL_FETCH)
.battleStyle("single")
.criticalHits(false)
.enemySpecies(SpeciesId.SHEDINJA)
.enemyAbility(AbilityId.WONDER_GUARD)
.enemyMoveset([MoveId.GRUDGE, MoveId.SPLASH]);
.enemySpecies(SpeciesId.RATTATA)
.startingLevel(100)
.enemyAbility(AbilityId.NO_GUARD);
});
it("should reduce the PP of the Pokemon's move to 0 when the user has fainted", async () => {
it("should reduce the PP of an attack that faints the user to 0", async () => {
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
const playerPokemon = game.scene.getPlayerPokemon();
game.move.select(MoveId.EMBER);
await game.move.selectEnemyMove(MoveId.GRUDGE);
game.move.use(MoveId.GUILLOTINE);
await game.move.forceEnemyMove(MoveId.GRUDGE);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to("BerryPhase");
await game.toEndOfTurn();
const playerMove = playerPokemon?.getMoveset().find(m => m.moveId === MoveId.EMBER);
expect(playerMove?.getPpRatio()).toBe(0);
// Ratatta should have fainted and consumed all of Guillotine's PP
const feebas = game.field.getPlayerPokemon();
const ratatta = game.field.getEnemyPokemon();
expect(ratatta).toHaveFainted();
expect(feebas).toHaveUsedPP(MoveId.GUILLOTINE, "all");
});
it("should remain in effect until the user's next move", async () => {
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
const playerPokemon = game.scene.getPlayerPokemon();
game.move.select(MoveId.SPLASH);
await game.move.selectEnemyMove(MoveId.GRUDGE);
game.move.use(MoveId.SPLASH);
await game.move.forceEnemyMove(MoveId.GRUDGE);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.toNextTurn();
game.move.select(MoveId.EMBER);
await game.move.selectEnemyMove(MoveId.SPLASH);
game.move.use(MoveId.GUILLOTINE);
await game.move.forceEnemyMove(MoveId.SPLASH);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to("BerryPhase");
await game.toEndOfTurn();
const playerMove = playerPokemon?.getMoveset().find(m => m.moveId === MoveId.EMBER);
expect(playerMove?.getPpRatio()).toBe(0);
const feebas = game.field.getPlayerPokemon();
const ratatta = game.field.getEnemyPokemon();
expect(ratatta).toHaveFainted();
expect(feebas).toHaveUsedPP(MoveId.GUILLOTINE, "all");
});
it("should not reduce the opponent's PP if the user dies to weather/indirect damage", async () => {
it("should not reduce PP if the user dies to weather/indirect damage", async () => {
// Opponent will be reduced to 1 HP by False Swipe, then faint to Sandstorm
game.override
.moveset([MoveId.FALSE_SWIPE])
.startingLevel(100)
.ability(AbilityId.SAND_STREAM)
.enemySpecies(SpeciesId.RATTATA);
await game.classicMode.startBattle([SpeciesId.GEODUDE]);
game.override.weather(WeatherType.SANDSTORM);
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
const enemyPokemon = game.scene.getEnemyPokemon();
const playerPokemon = game.scene.getPlayerPokemon();
game.move.select(MoveId.FALSE_SWIPE);
await game.move.selectEnemyMove(MoveId.GRUDGE);
game.move.use(MoveId.FALSE_SWIPE);
await game.move.forceEnemyMove(MoveId.GRUDGE);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to("BerryPhase");
await game.toEndOfTurn();
expect(enemyPokemon?.isFainted()).toBe(true);
const playerMove = playerPokemon?.getMoveset().find(m => m.moveId === MoveId.FALSE_SWIPE);
expect(playerMove?.getPpRatio()).toBeGreaterThan(0);
const feebas = game.field.getPlayerPokemon();
const ratatta = game.field.getEnemyPokemon();
expect(ratatta).toHaveFainted();
expect(feebas).toHaveUsedPP(MoveId.FALSE_SWIPE, 1);
});
});

View File

@ -2,6 +2,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 { MoveUseMode } from "#enums/move-use-mode";
import { SpeciesId } from "#enums/species-id";
import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser";
@ -29,12 +30,11 @@ describe("Moves - Spite", () => {
.criticalHits(false)
.enemySpecies(SpeciesId.MAGIKARP)
.enemyAbility(AbilityId.BALL_FETCH)
.enemyMoveset(MoveId.SPLASH)
.startingLevel(100)
.enemyLevel(100);
});
it("should reduce the PP of the target's last move by 4", async () => {
it("should reduce the PP of the target's last used move by 4", async () => {
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
const karp = game.field.getEnemyPokemon();
@ -48,7 +48,7 @@ describe("Moves - Spite", () => {
expect(karp).toHaveUsedPP(MoveId.TACKLE, 1);
game.move.use(MoveId.SPITE);
await game.move.forceEnemyMove(MoveId.TACKLE);
await game.move.forceEnemyMove(MoveId.SPLASH);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.toEndOfTurn();
@ -68,7 +68,39 @@ describe("Moves - Spite", () => {
const feebas = game.field.getPlayerPokemon();
expect(feebas).toHaveUsedMove({ move: MoveId.SPITE, result: MoveResult.FAIL });
expect(karp).toHaveUsedPP(MoveId.TACKLE, 1);
});
it("should fail if the target's last used move is out of PP", async () => {
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
const karp = game.field.getEnemyPokemon();
game.move.changeMoveset(karp, [MoveId.TACKLE]);
karp.moveset[0].ppUsed = 0;
game.move.use(MoveId.SPLASH);
await game.move.selectEnemyMove(MoveId.TACKLE);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.toEndOfTurn();
const feebas = game.field.getPlayerPokemon();
expect(feebas).toHaveUsedMove({ move: MoveId.SPITE, result: MoveResult.FAIL });
});
it("should fail if the target's last used move is not in their moveset", async () => {
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
const karp = game.field.getEnemyPokemon();
game.move.changeMoveset(karp, [MoveId.TACKLE]);
// Fake magikarp having used Splash the turn prior
karp.pushMoveHistory({ move: MoveId.SPLASH, targets: [BattlerIndex.ENEMY], useMode: MoveUseMode.NORMAL });
game.move.use(MoveId.SPITE);
await game.move.selectEnemyMove(MoveId.TACKLE);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.toEndOfTurn();
const feebas = game.field.getPlayerPokemon();
expect(feebas).toHaveUsedMove({ move: MoveId.SPITE, result: MoveResult.FAIL });
});
it("should ignore virtual and Dancer-induced moves", async () => {