2024-09-25 17:17:46 -07:00
|
|
|
import { SubstituteTag } from "#app/data/battler-tags";
|
2024-11-02 09:47:08 -07:00
|
|
|
import { MoveResult } from "#app/field/pokemon";
|
2024-09-25 17:17:46 -07:00
|
|
|
import { Abilities } from "#enums/abilities";
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
2025-02-22 22:52:07 -06:00
|
|
|
import GameManager from "#test/testUtils/gameManager";
|
2024-09-25 17:17:46 -07:00
|
|
|
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
|
2024-10-04 13:08:31 +08:00
|
|
|
.moveset([ Moves.SHED_TAIL ])
|
2024-09-25 17:17:46 -07:00
|
|
|
.battleType("single")
|
|
|
|
.enemySpecies(Species.SNORLAX)
|
|
|
|
.enemyAbility(Abilities.BALL_FETCH)
|
|
|
|
.enemyMoveset(Moves.SPLASH);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("transfers a Substitute doll to the switched in Pokemon", async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.MAGIKARP, Species.FEEBAS ]);
|
2024-09-25 17:17:46 -07:00
|
|
|
|
|
|
|
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));
|
|
|
|
});
|
2024-11-02 09:47:08 -07:00
|
|
|
|
|
|
|
it("should fail if no ally is available to switch in", async () => {
|
|
|
|
await game.classicMode.startBattle([ Species.MAGIKARP ]);
|
|
|
|
|
|
|
|
const magikarp = game.scene.getPlayerPokemon()!;
|
2024-11-03 18:53:52 -08:00
|
|
|
expect(game.scene.getPlayerParty().length).toBe(1);
|
2024-11-02 09:47:08 -07:00
|
|
|
|
|
|
|
game.move.select(Moves.SHED_TAIL);
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
|
|
|
|
expect(magikarp.isOnField()).toBeTruthy();
|
|
|
|
expect(magikarp.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
|
|
|
});
|
2024-09-25 17:17:46 -07:00
|
|
|
});
|