pokerogue/test/moves/shed-tail.test.ts
Bertie690 8ae898ec30
[Move] Update documentation for AddSubstituteAttr; fix Shed Tail incorrect error message (#6873)
* [Move] Update documentation for attribute; fix Shed Tail incorrect error message

* Add another test

---------

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
Co-authored-by: Fabi <192151969+fabske0@users.noreply.github.com>
2025-12-20 20:26:51 +00:00

83 lines
2.7 KiB
TypeScript

import { SubstituteTag } from "#data/battler-tags";
import { AbilityId } from "#enums/ability-id";
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 i18next from "i18next";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } 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([MoveId.SHED_TAIL])
.battleStyle("single")
.enemySpecies(SpeciesId.SNORLAX)
.enemyAbility(AbilityId.BALL_FETCH)
.enemyMoveset(MoveId.SPLASH);
});
it("transfers a Substitute doll to the switched in Pokemon", async () => {
await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.FEEBAS]);
const magikarp = game.field.getPlayerPokemon();
game.move.select(MoveId.SHED_TAIL);
game.doSelectPartyPokemon(1);
await game.phaseInterceptor.to("TurnEndPhase", false);
const feebas = game.field.getPlayerPokemon();
const substituteTag = feebas.getTag(SubstituteTag);
expect(feebas).not.toBe(magikarp);
expect(feebas.hp).toBe(feebas.getMaxHp());
// Note: Altered the test to be consistent with the correct HP cost :yipeevee_static:
expect(magikarp.hp).toBe(Math.floor(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([SpeciesId.MAGIKARP]);
const magikarp = game.field.getPlayerPokemon();
expect(game.scene.getPlayerParty().length).toBe(1);
game.move.select(MoveId.SHED_TAIL);
await game.phaseInterceptor.to("TurnEndPhase", false);
expect(magikarp.isOnField()).toBeTruthy();
expect(magikarp.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
});
it("should show the correct failure message between 26-50% HP", async () => {
await game.classicMode.startBattle([SpeciesId.FEEBAS, SpeciesId.ABRA]);
const feebas = game.field.getPlayerPokemon();
feebas.hp *= 0.4;
game.move.use(MoveId.SHED_TAIL);
await game.toEndOfTurn();
expect(feebas).toHaveUsedMove({ move: MoveId.SHED_TAIL, result: MoveResult.FAIL });
expect(game).toHaveShownMessage(i18next.t("moveTriggers:substituteNotEnoughHp"));
});
});