mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-12-24 18:49:16 +01:00
140 lines
5.4 KiB
TypeScript
140 lines
5.4 KiB
TypeScript
import { RandomMoveAttr } from "#app/data/moves/move";
|
|
import { Abilities } from "#app/enums/abilities";
|
|
import { MoveResult } from "#app/field/pokemon";
|
|
import { getPokemonNameWithAffix } from "#app/messages";
|
|
import { Moves } from "#enums/moves";
|
|
import { Species } from "#enums/species";
|
|
import { WeatherType } from "#enums/weather-type";
|
|
import GameManager from "#test/testUtils/gameManager";
|
|
import i18next from "i18next";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
describe("Moves - Chilly Reception", () => {
|
|
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
|
|
.battleStyle("single")
|
|
.moveset([Moves.CHILLY_RECEPTION, Moves.SNOWSCAPE, Moves.SPLASH, Moves.METRONOME])
|
|
.enemyMoveset(Moves.SPLASH)
|
|
.enemyAbility(Abilities.BALL_FETCH)
|
|
.ability(Abilities.BALL_FETCH);
|
|
});
|
|
|
|
it("should display message before use, switch the user out and change the weather to snow", async () => {
|
|
await game.classicMode.startBattle([Species.SLOWKING, Species.MEOWTH]);
|
|
|
|
const [slowking, meowth] = game.scene.getPlayerParty();
|
|
|
|
game.move.select(Moves.CHILLY_RECEPTION);
|
|
game.doSelectPartyPokemon(1);
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
expect(game.scene.getPlayerPokemon()).toBe(meowth);
|
|
expect(slowking.isOnField()).toBe(false);
|
|
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
|
expect(game.textInterceptor.logs).toContain(
|
|
i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(slowking) }),
|
|
);
|
|
});
|
|
|
|
it("should still change weather if user can't switch out", async () => {
|
|
await game.classicMode.startBattle([Species.SLOWKING]);
|
|
|
|
game.move.select(Moves.CHILLY_RECEPTION);
|
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
|
|
expect(game.scene.getPlayerPokemon()?.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
|
});
|
|
|
|
it("should still switch out even if weather cannot be changed", async () => {
|
|
await game.classicMode.startBattle([Species.SLOWKING, Species.MEOWTH]);
|
|
|
|
expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.SNOW);
|
|
|
|
const [slowking, meowth] = game.scene.getPlayerParty();
|
|
|
|
game.move.select(Moves.SNOWSCAPE);
|
|
await game.toNextTurn();
|
|
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
|
|
game.move.select(Moves.CHILLY_RECEPTION);
|
|
game.doSelectPartyPokemon(1);
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
|
expect(game.scene.getPlayerPokemon()).toBe(meowth);
|
|
expect(slowking.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
|
});
|
|
|
|
it("should fail if neither weather change nor switch out succeeds", async () => {
|
|
await game.classicMode.startBattle([Species.SLOWKING]);
|
|
|
|
expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.SNOW);
|
|
|
|
game.move.select(Moves.SNOWSCAPE);
|
|
await game.toNextTurn();
|
|
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
|
|
game.move.select(Moves.CHILLY_RECEPTION);
|
|
game.doSelectPartyPokemon(1);
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
|
|
expect(game.scene.getPlayerPokemon()?.species.speciesId).toBe(Species.SLOWKING);
|
|
expect(game.scene.getPlayerPokemon()?.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
|
});
|
|
|
|
// TODO: Fix this - it's really easy (just check the current MovePhase's `virtual` flag)
|
|
it.todo("should not display message if called indirectly", async () => {
|
|
vi.spyOn(RandomMoveAttr.prototype, "getMoveOverride").mockReturnValue(Moves.CHILLY_RECEPTION);
|
|
await game.classicMode.startBattle([Species.SLOWKING, Species.MEOWTH]);
|
|
|
|
const [slowking, meowth] = game.scene.getPlayerParty();
|
|
|
|
game.move.select(Moves.METRONOME);
|
|
game.doSelectPartyPokemon(1);
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
expect(game.scene.getPlayerPokemon()).toBe(meowth);
|
|
expect(slowking.isOnField()).toBe(false);
|
|
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
|
expect(game.textInterceptor.logs).not.toContain(
|
|
i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(slowking) }),
|
|
);
|
|
});
|
|
|
|
// Bugcheck test for enemy AI bug
|
|
it("check case - enemy not selecting chilly reception doesn't change weather", async () => {
|
|
game.override.enemyMoveset([Moves.CHILLY_RECEPTION, Moves.TACKLE]);
|
|
await game.classicMode.startBattle([Species.SLOWKING, Species.MEOWTH]);
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
await game.forceEnemyMove(Moves.TACKLE);
|
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
expect(game.scene.arena.weather?.weatherType).toBeUndefined();
|
|
});
|
|
});
|