2024-08-22 06:49:33 -07:00
|
|
|
import { Abilities } from "#app/enums/abilities";
|
|
|
|
import { StatusEffect } from "#app/enums/status-effect";
|
|
|
|
import { SwitchPhase } from "#app/phases/switch-phase";
|
|
|
|
import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
2024-08-06 23:29:51 -07:00
|
|
|
import GameManager from "#app/test/utils/gameManager";
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
|
|
|
|
describe("Moves - U-turn", () => {
|
|
|
|
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
|
|
|
|
.battleType("single")
|
|
|
|
.enemySpecies(Species.GENGAR)
|
|
|
|
.startingLevel(90)
|
|
|
|
.startingWave(97)
|
|
|
|
.moveset([Moves.U_TURN])
|
2024-09-09 09:55:11 -07:00
|
|
|
.enemyMoveset(Moves.SPLASH)
|
2024-08-06 23:29:51 -07:00
|
|
|
.disableCrits();
|
|
|
|
});
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
it("triggers regenerator a single time when a regenerator user switches out with u-turn", async () => {
|
2024-08-06 23:29:51 -07:00
|
|
|
// arrange
|
|
|
|
const playerHp = 1;
|
|
|
|
game.override.ability(Abilities.REGENERATOR);
|
|
|
|
await game.startBattle([
|
|
|
|
Species.RAICHU,
|
|
|
|
Species.SHUCKLE
|
|
|
|
]);
|
2024-08-07 09:23:12 -07:00
|
|
|
game.scene.getPlayerPokemon()!.hp = playerHp;
|
2024-08-06 23:29:51 -07:00
|
|
|
|
|
|
|
// act
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.U_TURN);
|
2024-08-06 23:29:51 -07:00
|
|
|
game.doSelectPartyPokemon(1);
|
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
|
|
|
|
// assert
|
|
|
|
expect(game.scene.getParty()[1].hp).toEqual(Math.floor(game.scene.getParty()[1].getMaxHp() * 0.33 + playerHp));
|
|
|
|
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
2024-08-07 09:23:12 -07:00
|
|
|
expect(game.scene.getPlayerPokemon()!.species.speciesId).toBe(Species.SHUCKLE);
|
2024-08-06 23:29:51 -07:00
|
|
|
}, 20000);
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
it("triggers rough skin on the u-turn user before a new pokemon is switched in", async () => {
|
2024-08-06 23:29:51 -07:00
|
|
|
// arrange
|
|
|
|
game.override.enemyAbility(Abilities.ROUGH_SKIN);
|
|
|
|
await game.startBattle([
|
|
|
|
Species.RAICHU,
|
|
|
|
Species.SHUCKLE
|
|
|
|
]);
|
|
|
|
|
|
|
|
// act
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.U_TURN);
|
2024-08-06 23:29:51 -07:00
|
|
|
game.doSelectPartyPokemon(1);
|
|
|
|
await game.phaseInterceptor.to(SwitchPhase, false);
|
|
|
|
|
|
|
|
// assert
|
2024-08-07 09:23:12 -07:00
|
|
|
const playerPkm = game.scene.getPlayerPokemon()!;
|
|
|
|
expect(playerPkm.hp).not.toEqual(playerPkm.getMaxHp());
|
|
|
|
expect(game.scene.getEnemyPokemon()!.battleData.abilityRevealed).toBe(true); // proxy for asserting ability activated
|
|
|
|
expect(playerPkm.species.speciesId).toEqual(Species.RAICHU);
|
2024-08-06 23:29:51 -07:00
|
|
|
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
|
|
|
|
}, 20000);
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
it("triggers contact abilities on the u-turn user (eg poison point) before a new pokemon is switched in", async () => {
|
2024-08-06 23:29:51 -07:00
|
|
|
// arrange
|
|
|
|
game.override.enemyAbility(Abilities.POISON_POINT);
|
|
|
|
await game.startBattle([
|
|
|
|
Species.RAICHU,
|
|
|
|
Species.SHUCKLE
|
|
|
|
]);
|
2024-08-07 09:23:12 -07:00
|
|
|
vi.spyOn(game.scene.getEnemyPokemon()!, "randSeedInt").mockReturnValue(0);
|
2024-08-06 23:29:51 -07:00
|
|
|
|
|
|
|
// act
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.U_TURN);
|
2024-08-06 23:29:51 -07:00
|
|
|
await game.phaseInterceptor.to(SwitchPhase, false);
|
|
|
|
|
|
|
|
// assert
|
2024-08-07 09:23:12 -07:00
|
|
|
const playerPkm = game.scene.getPlayerPokemon()!;
|
|
|
|
expect(playerPkm.status?.effect).toEqual(StatusEffect.POISON);
|
|
|
|
expect(playerPkm.species.speciesId).toEqual(Species.RAICHU);
|
|
|
|
expect(game.scene.getEnemyPokemon()!.battleData.abilityRevealed).toBe(true); // proxy for asserting ability activated
|
2024-08-06 23:29:51 -07:00
|
|
|
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
|
|
|
|
}, 20000);
|
|
|
|
});
|