mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-03-10 03:48:27 +00:00
* Update `battle-scene.ts` and `data/field/pokemon.ts` `battle-scene.ts` changes: - `getParty()` renamed to `getPlayerParty()` for clarity - `getNonSwitchedXPokemon()` consolidated into `getXPokemon()` - Some tsdocs were added/updated for `getXParty()`, `getXField()` and `getXPokemon()`; and those functions were explicitly marked as `public` - Helper function `getPokemonAllowedInBattle()` added `pokemon.ts` changes: - `isAllowed()` renamed to `isAllowedInChallenge()` for clarity - A redundant check for an active scene is removed in `isActive()` - Some tsdocs were added/updated for `isFainted()`, `isAllowedInChallenge()`, `isAllowedInBattle()` and `isActive()`; and those functions were explicitly marked as `public` - `isFainted()` now checks for `hp <= 0` instead of `!hp` Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Backport eslint change to reduce merge conflicts * Fix merge issues --------- Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: Tempoanon <163687446+Tempo-anon@users.noreply.github.com>
108 lines
3.9 KiB
TypeScript
108 lines
3.9 KiB
TypeScript
import { Abilities } from "#enums/abilities";
|
|
import { Moves } from "#enums/moves";
|
|
import { Species } from "#enums/species";
|
|
import { StatusEffect } from "#enums/status-effect";
|
|
import GameManager from "#test/utils/gameManager";
|
|
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 ])
|
|
.enemyMoveset(Moves.SPLASH)
|
|
.disableCrits();
|
|
});
|
|
|
|
it("triggers regenerator a single time when a regenerator user switches out with u-turn", async () => {
|
|
// arrange
|
|
const playerHp = 1;
|
|
game.override.ability(Abilities.REGENERATOR);
|
|
await game.classicMode.startBattle([ Species.RAICHU, Species.SHUCKLE ]);
|
|
game.scene.getPlayerPokemon()!.hp = playerHp;
|
|
|
|
// act
|
|
game.move.select(Moves.U_TURN);
|
|
game.doSelectPartyPokemon(1);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
// assert
|
|
expect(game.scene.getPlayerParty()[1].hp).toEqual(Math.floor(game.scene.getPlayerParty()[1].getMaxHp() * 0.33 + playerHp));
|
|
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
|
expect(game.scene.getPlayerPokemon()!.species.speciesId).toBe(Species.SHUCKLE);
|
|
}, 20000);
|
|
|
|
it("triggers rough skin on the u-turn user before a new pokemon is switched in", async () => {
|
|
// arrange
|
|
game.override.enemyAbility(Abilities.ROUGH_SKIN);
|
|
await game.classicMode.startBattle([ Species.RAICHU, Species.SHUCKLE ]);
|
|
|
|
// act
|
|
game.move.select(Moves.U_TURN);
|
|
game.doSelectPartyPokemon(1);
|
|
await game.phaseInterceptor.to("SwitchPhase", false);
|
|
|
|
// assert
|
|
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);
|
|
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
|
|
}, 20000);
|
|
|
|
it("triggers contact abilities on the u-turn user (eg poison point) before a new pokemon is switched in", async () => {
|
|
// arrange
|
|
game.override.enemyAbility(Abilities.POISON_POINT);
|
|
await game.classicMode.startBattle([ Species.RAICHU, Species.SHUCKLE ]);
|
|
vi.spyOn(game.scene.getEnemyPokemon()!, "randSeedInt").mockReturnValue(0);
|
|
|
|
// act
|
|
game.move.select(Moves.U_TURN);
|
|
await game.phaseInterceptor.to("SwitchPhase", false);
|
|
|
|
// assert
|
|
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
|
|
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
|
|
}, 20000);
|
|
|
|
it("still forces a switch if u-turn KO's the opponent", async () => {
|
|
game.override.startingLevel(1000); // Ensure that U-Turn KO's the opponent
|
|
await game.classicMode.startBattle([
|
|
Species.RAICHU,
|
|
Species.SHUCKLE
|
|
]);
|
|
const enemy = game.scene.getEnemyPokemon()!;
|
|
|
|
// KO the opponent with U-Turn
|
|
game.move.select(Moves.U_TURN);
|
|
game.doSelectPartyPokemon(1);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
expect(enemy.isFainted()).toBe(true);
|
|
|
|
// Check that U-Turn forced a switch
|
|
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
|
expect(game.scene.getPlayerPokemon()!.species.speciesId).toBe(Species.SHUCKLE);
|
|
});
|
|
});
|