Add tests for reviver seed

This commit is contained in:
Christopher Schmidt 2025-01-26 22:25:48 -05:00
parent c3a918f6b9
commit 73538df5d0
1 changed files with 117 additions and 0 deletions

View File

@ -0,0 +1,117 @@
import { allMoves } from "#app/data/move";
import { BattlerTagType } from "#app/enums/battler-tag-type";
import type { PokemonInstantReviveModifier } from "#app/modifier/modifier";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
describe("Items - Reviver Seed", () => {
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
.moveset([ Moves.SPLASH, Moves.TACKLE, Moves.ENDURE ])
.ability(Abilities.BALL_FETCH)
.battleType("single")
.disableCrits()
.enemySpecies(Species.MAGIKARP)
.enemyAbility(Abilities.BALL_FETCH)
.startingHeldItems([{ name: "REVIVER_SEED" }])
.enemyHeldItems([{ name: "REVIVER_SEED" }])
.enemyMoveset(Moves.SPLASH);
vi.spyOn(allMoves[Moves.SHEER_COLD], "accuracy", "get").mockReturnValue(100);
vi.spyOn(allMoves[Moves.LEECH_SEED], "accuracy", "get").mockReturnValue(100);
vi.spyOn(allMoves[Moves.WHIRLPOOL], "accuracy", "get").mockReturnValue(100);
vi.spyOn(allMoves[Moves.WILL_O_WISP], "accuracy", "get").mockReturnValue(100);
});
it.each([
{ moveType: "Special Move", move: Moves.WATER_GUN },
{ moveType: "Physical Move", move: Moves.TACKLE },
{ moveType: "Fixed Damage Move", move: Moves.SEISMIC_TOSS },
{ moveType: "Final Gambit", move: Moves.FINAL_GAMBIT },
{ moveType: "Counter", move: Moves.COUNTER },
{ moveType: "OHKO", move: Moves.SHEER_COLD }
])("should activate the holder's reviver seed from a $moveType", async ({ move }) => {
game.override
.enemyLevel(100)
.startingLevel(1)
.enemyMoveset(move);
await game.classicMode.startBattle([ Species.MAGIKARP, Species.FEEBAS ]);
const player = game.scene.getPlayerPokemon()!;
player.damageAndUpdate(player.hp - 1);
const reviverSeed = player.getHeldItems()[0] as PokemonInstantReviveModifier;
vi.spyOn(reviverSeed, "apply");
game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to("BerryPhase");
expect(reviverSeed.apply).toHaveReturnedWith(true); // Reviver Seed triggers
expect(player.isFainted()).toBeFalsy();
});
it("should activate the holder's reviver seed from confusion self-hit", async () => {
game.override
.enemyLevel(1)
.startingLevel(100)
.enemyMoveset(Moves.SPLASH);
await game.classicMode.startBattle([ Species.MAGIKARP, Species.FEEBAS ]);
const player = game.scene.getPlayerPokemon()!;
player.damageAndUpdate(player.hp - 1);
player.addTag(BattlerTagType.CONFUSED, 3);
const reviverSeed = player.getHeldItems()[0] as PokemonInstantReviveModifier;
vi.spyOn(reviverSeed, "apply");
vi.spyOn(player, "randSeedInt").mockReturnValue(0); // Force confusion self-hit
game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to("BerryPhase");
expect(reviverSeed.apply).toHaveReturnedWith(true); // Reviver Seed triggers
expect(player.isFainted()).toBeFalsy();
});
//Need to fix some of tests, something wrong with the enemy fainting, wrong phase being chosen.. not sure
it.each([
//{ moveType: "Damaging Move Chip Damage", move: Moves.SALT_CURE },
//{ moveType: "Chip Damage", move: Moves.LEECH_SEED },
//{ moveType: "Trapping Chip Damage", move: Moves.WHIRLPOOL },
{ moveType: "Status Effect Damage", move: Moves.WILL_O_WISP },
{ moveType: "Weather", move: Moves.SANDSTORM }
])("should not activate the holder's reviver seed from $moveType", async ({ move }) => {
game.override
.enemyLevel(1)
.startingLevel(100)
.enemySpecies(Species.MAGIKARP)
.moveset(move)
.enemyMoveset(Moves.SPLASH);
await game.classicMode.startBattle([ Species.MAGIKARP, Species.FEEBAS ]);
const enemy = game.scene.getEnemyPokemon()!;
enemy.damageAndUpdate(enemy.hp - 1);
const enemySeed = enemy.getHeldItems()[0] as PokemonInstantReviveModifier;
vi.spyOn(enemySeed, "apply");
game.move.select(move);
await game.phaseInterceptor.to("BerryPhase");
expect(enemy.isFainted()).toBeTruthy();
});
});