mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-03-06 18:09:10 +00:00
* move test folder * Update vitest files * rename test/utils to test/testUtils * Remove stray utils/gameManager Got put back from a rebase
72 lines
2.4 KiB
TypeScript
72 lines
2.4 KiB
TypeScript
import { SubstituteTag } from "#app/data/battler-tags";
|
|
import { MoveResult } from "#app/field/pokemon";
|
|
import { Abilities } from "#enums/abilities";
|
|
import { Moves } from "#enums/moves";
|
|
import { Species } from "#enums/species";
|
|
import GameManager from "#test/testUtils/gameManager";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, it, expect } from "vitest";
|
|
|
|
describe("Moves - Shed Tail", () => {
|
|
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.SHED_TAIL ])
|
|
.battleType("single")
|
|
.enemySpecies(Species.SNORLAX)
|
|
.enemyAbility(Abilities.BALL_FETCH)
|
|
.enemyMoveset(Moves.SPLASH);
|
|
});
|
|
|
|
it("transfers a Substitute doll to the switched in Pokemon", async () => {
|
|
await game.classicMode.startBattle([ Species.MAGIKARP, Species.FEEBAS ]);
|
|
|
|
const magikarp = game.scene.getPlayerPokemon()!;
|
|
|
|
game.move.select(Moves.SHED_TAIL);
|
|
game.doSelectPartyPokemon(1);
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
const feebas = game.scene.getPlayerPokemon()!;
|
|
const substituteTag = feebas.getTag(SubstituteTag);
|
|
|
|
expect(feebas).not.toBe(magikarp);
|
|
expect(feebas.hp).toBe(feebas.getMaxHp());
|
|
// Note: Shed Tail's HP cost is currently not accurate to mainline, as it
|
|
// should cost ceil(maxHP / 2) instead of max(floor(maxHp / 2), 1). The current
|
|
// implementation is consistent with Substitute's HP cost logic, but that's not
|
|
// the case in mainline for some reason :regiDespair:.
|
|
expect(magikarp.hp).toBe(Math.ceil(magikarp.getMaxHp() / 2));
|
|
expect(substituteTag).toBeDefined();
|
|
expect(substituteTag?.hp).toBe(Math.floor(magikarp.getMaxHp() / 4));
|
|
});
|
|
|
|
it("should fail if no ally is available to switch in", async () => {
|
|
await game.classicMode.startBattle([ Species.MAGIKARP ]);
|
|
|
|
const magikarp = game.scene.getPlayerPokemon()!;
|
|
expect(game.scene.getPlayerParty().length).toBe(1);
|
|
|
|
game.move.select(Moves.SHED_TAIL);
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
expect(magikarp.isOnField()).toBeTruthy();
|
|
expect(magikarp.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
|
});
|
|
});
|