mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-03-09 11:31:49 +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>
102 lines
3.7 KiB
TypeScript
102 lines
3.7 KiB
TypeScript
import { StatusEffect } from "#app/enums/status-effect";
|
|
import { CommandPhase } from "#app/phases/command-phase";
|
|
import { Abilities } from "#enums/abilities";
|
|
import { Moves } from "#enums/moves";
|
|
import { Species } from "#enums/species";
|
|
import GameManager from "#test/utils/gameManager";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, it, expect, vi } from "vitest";
|
|
|
|
describe("Moves - Aromatherapy", () => {
|
|
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.AROMATHERAPY, Moves.SPLASH ])
|
|
.statusEffect(StatusEffect.BURN)
|
|
.battleType("double")
|
|
.enemyAbility(Abilities.BALL_FETCH)
|
|
.enemyMoveset(Moves.SPLASH);
|
|
});
|
|
|
|
it("should cure status effect of the user, its ally, and all party pokemon", async () => {
|
|
await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA, Species.RATTATA ]);
|
|
const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getPlayerParty();
|
|
|
|
vi.spyOn(leftPlayer, "resetStatus");
|
|
vi.spyOn(rightPlayer, "resetStatus");
|
|
vi.spyOn(partyPokemon, "resetStatus");
|
|
|
|
game.move.select(Moves.AROMATHERAPY, 0);
|
|
await game.phaseInterceptor.to(CommandPhase);
|
|
game.move.select(Moves.SPLASH, 1);
|
|
await game.toNextTurn();
|
|
|
|
expect(leftPlayer.resetStatus).toHaveBeenCalledOnce();
|
|
expect(rightPlayer.resetStatus).toHaveBeenCalledOnce();
|
|
expect(partyPokemon.resetStatus).toHaveBeenCalledOnce();
|
|
|
|
expect(leftPlayer.status?.effect).toBeUndefined();
|
|
expect(rightPlayer.status?.effect).toBeUndefined();
|
|
expect(partyPokemon.status?.effect).toBeUndefined();
|
|
});
|
|
|
|
it("should not cure status effect of the target/target's allies", async () => {
|
|
game.override.enemyStatusEffect(StatusEffect.BURN);
|
|
await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA ]);
|
|
const [ leftOpp, rightOpp ] = game.scene.getEnemyField();
|
|
|
|
vi.spyOn(leftOpp, "resetStatus");
|
|
vi.spyOn(rightOpp, "resetStatus");
|
|
|
|
game.move.select(Moves.AROMATHERAPY, 0);
|
|
await game.phaseInterceptor.to(CommandPhase);
|
|
game.move.select(Moves.SPLASH, 1);
|
|
await game.toNextTurn();
|
|
|
|
expect(leftOpp.resetStatus).toHaveBeenCalledTimes(0);
|
|
expect(rightOpp.resetStatus).toHaveBeenCalledTimes(0);
|
|
|
|
expect(leftOpp.status?.effect).toBeTruthy();
|
|
expect(rightOpp.status?.effect).toBeTruthy();
|
|
|
|
expect(leftOpp.status?.effect).toBe(StatusEffect.BURN);
|
|
expect(rightOpp.status?.effect).toBe(StatusEffect.BURN);
|
|
});
|
|
|
|
it("should not cure status effect of allies ON FIELD with Sap Sipper, should still cure allies in party", async () => {
|
|
game.override.ability(Abilities.SAP_SIPPER);
|
|
await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA, Species.RATTATA ]);
|
|
const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getPlayerParty();
|
|
|
|
vi.spyOn(leftPlayer, "resetStatus");
|
|
vi.spyOn(rightPlayer, "resetStatus");
|
|
vi.spyOn(partyPokemon, "resetStatus");
|
|
|
|
game.move.select(Moves.AROMATHERAPY, 0);
|
|
await game.phaseInterceptor.to(CommandPhase);
|
|
game.move.select(Moves.SPLASH, 1);
|
|
await game.toNextTurn();
|
|
|
|
expect(leftPlayer.resetStatus).toHaveBeenCalledOnce();
|
|
expect(rightPlayer.resetStatus).toHaveBeenCalledTimes(0);
|
|
expect(partyPokemon.resetStatus).toHaveBeenCalledOnce();
|
|
|
|
expect(leftPlayer.status?.effect).toBeUndefined();
|
|
expect(rightPlayer.status?.effect).toBe(StatusEffect.BURN);
|
|
expect(partyPokemon.status?.effect).toBeUndefined();
|
|
});
|
|
});
|