mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-11-19 09:41:22 +01: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>
92 lines
3.1 KiB
TypeScript
92 lines
3.1 KiB
TypeScript
import { Abilities } from "#enums/abilities";
|
|
import { Moves } from "#enums/moves";
|
|
import { Species } from "#enums/species";
|
|
import { Type } from "#app/data/type";
|
|
import GameManager from "#test/utils/gameManager";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
|
|
describe("Abilities - Mimicry", () => {
|
|
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.SPLASH ])
|
|
.ability(Abilities.MIMICRY)
|
|
.battleType("single")
|
|
.disableCrits()
|
|
.enemySpecies(Species.MAGIKARP)
|
|
.enemyMoveset(Moves.SPLASH);
|
|
});
|
|
|
|
it("Mimicry activates after the Pokémon with Mimicry is switched in while terrain is present, or whenever there is a change in terrain", async () => {
|
|
game.override.enemyAbility(Abilities.MISTY_SURGE);
|
|
await game.classicMode.startBattle([ Species.FEEBAS, Species.ABRA ]);
|
|
|
|
const [ playerPokemon1, playerPokemon2 ] = game.scene.getPlayerParty();
|
|
game.move.select(Moves.SPLASH);
|
|
await game.toNextTurn();
|
|
expect(playerPokemon1.getTypes().includes(Type.FAIRY)).toBe(true);
|
|
|
|
game.doSwitchPokemon(1);
|
|
await game.toNextTurn();
|
|
|
|
expect(playerPokemon2.getTypes().includes(Type.FAIRY)).toBe(true);
|
|
});
|
|
|
|
it("Pokemon should revert back to its original, root type once terrain ends", async () => {
|
|
game.override
|
|
.moveset([ Moves.SPLASH, Moves.TRANSFORM ])
|
|
.enemyAbility(Abilities.MIMICRY)
|
|
.enemyMoveset([ Moves.SPLASH, Moves.PSYCHIC_TERRAIN ]);
|
|
await game.classicMode.startBattle([ Species.REGIELEKI ]);
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon();
|
|
game.move.select(Moves.TRANSFORM);
|
|
await game.forceEnemyMove(Moves.PSYCHIC_TERRAIN);
|
|
await game.toNextTurn();
|
|
expect(playerPokemon?.getTypes().includes(Type.PSYCHIC)).toBe(true);
|
|
|
|
if (game.scene.arena.terrain) {
|
|
game.scene.arena.terrain.turnsLeft = 1;
|
|
}
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
await game.forceEnemyMove(Moves.SPLASH);
|
|
await game.toNextTurn();
|
|
expect(playerPokemon?.getTypes().includes(Type.ELECTRIC)).toBe(true);
|
|
});
|
|
|
|
it("If the Pokemon is under the effect of a type-adding move and an equivalent terrain activates, the move's effect disappears", async () => {
|
|
game.override
|
|
.enemyMoveset([ Moves.FORESTS_CURSE, Moves.GRASSY_TERRAIN ]);
|
|
await game.classicMode.startBattle([ Species.FEEBAS ]);
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon();
|
|
game.move.select(Moves.SPLASH);
|
|
await game.forceEnemyMove(Moves.FORESTS_CURSE);
|
|
await game.toNextTurn();
|
|
|
|
expect(playerPokemon?.summonData.addedType).toBe(Type.GRASS);
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
await game.forceEnemyMove(Moves.GRASSY_TERRAIN);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
expect(playerPokemon?.summonData.addedType).toBeNull();
|
|
expect(playerPokemon?.getTypes().includes(Type.GRASS)).toBe(true);
|
|
});
|
|
});
|