|
|
|
@ -1,14 +1,11 @@
|
|
|
|
|
import { RandomMoveAttr } from "#app/data/moves/move";
|
|
|
|
|
import { MoveResult } from "#enums/move-result";
|
|
|
|
|
import { getPokemonNameWithAffix } from "#app/messages";
|
|
|
|
|
import { AbilityId } from "#enums/ability-id";
|
|
|
|
|
import { MoveId } from "#enums/move-id";
|
|
|
|
|
import { SpeciesId } from "#enums/species-id";
|
|
|
|
|
import { AbilityId } from "#app/enums/ability-id";
|
|
|
|
|
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";
|
|
|
|
|
//import { TurnInitPhase } from "#app/phases/turn-init-phase";
|
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
|
|
|
|
|
|
|
|
describe("Moves - Chilly Reception", () => {
|
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
@ -28,121 +25,95 @@ describe("Moves - Chilly Reception", () => {
|
|
|
|
|
game = new GameManager(phaserGame);
|
|
|
|
|
game.override
|
|
|
|
|
.battleStyle("single")
|
|
|
|
|
.moveset([MoveId.CHILLY_RECEPTION, MoveId.SNOWSCAPE, MoveId.SPLASH, MoveId.METRONOME])
|
|
|
|
|
.moveset([MoveId.CHILLY_RECEPTION, MoveId.SNOWSCAPE])
|
|
|
|
|
.enemyMoveset(MoveId.SPLASH)
|
|
|
|
|
.enemyAbility(AbilityId.BALL_FETCH)
|
|
|
|
|
.ability(AbilityId.BALL_FETCH);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should display message before use, switch the user out and change the weather to snow", async () => {
|
|
|
|
|
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
|
|
|
|
|
|
|
|
|
const [slowking, meowth] = game.scene.getPlayerParty();
|
|
|
|
|
|
|
|
|
|
game.move.select(MoveId.CHILLY_RECEPTION);
|
|
|
|
|
game.doSelectPartyPokemon(1);
|
|
|
|
|
await game.toEndOfTurn();
|
|
|
|
|
|
|
|
|
|
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 () => {
|
|
|
|
|
it("should still change the weather if user can't switch out", async () => {
|
|
|
|
|
await game.classicMode.startBattle([SpeciesId.SLOWKING]);
|
|
|
|
|
|
|
|
|
|
game.move.select(MoveId.CHILLY_RECEPTION);
|
|
|
|
|
await game.toEndOfTurn();
|
|
|
|
|
|
|
|
|
|
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 () => {
|
|
|
|
|
it("should switch out even if it's snowing", async () => {
|
|
|
|
|
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
|
|
|
|
|
|
|
|
|
expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.SNOW);
|
|
|
|
|
|
|
|
|
|
const [slowking, meowth] = game.scene.getPlayerParty();
|
|
|
|
|
|
|
|
|
|
// first turn set up snow with snowscape, try chilly reception on second turn
|
|
|
|
|
game.move.select(MoveId.SNOWSCAPE);
|
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to("TurnInitPhase", false);
|
|
|
|
|
game.move.select(MoveId.CHILLY_RECEPTION);
|
|
|
|
|
game.doSelectPartyPokemon(1);
|
|
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
|
|
|
expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MEOWTH);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("happy case - switch out and weather changes", async () => {
|
|
|
|
|
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
|
|
|
|
|
|
|
|
|
game.move.select(MoveId.CHILLY_RECEPTION);
|
|
|
|
|
game.doSelectPartyPokemon(1);
|
|
|
|
|
// TODO: Uncomment lines once wimp out PR fixes force switches to not reset summon data immediately
|
|
|
|
|
// await game.phaseInterceptor.to("SwitchSummonPhase", false);
|
|
|
|
|
// expect(slowking.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
|
|
|
|
|
|
|
|
|
await game.toEndOfTurn();
|
|
|
|
|
|
|
|
|
|
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.isOnField()).toBe(false);
|
|
|
|
|
expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MEOWTH);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Source: https://replay.pokemonshowdown.com/gen9ou-2367532550
|
|
|
|
|
it("should fail (while still displaying message) if neither weather change nor switch out succeeds", async () => {
|
|
|
|
|
await game.classicMode.startBattle([SpeciesId.SLOWKING]);
|
|
|
|
|
// enemy uses another move and weather doesn't change
|
|
|
|
|
it("check case - enemy not selecting chilly reception doesn't change weather ", async () => {
|
|
|
|
|
game.override.battleStyle("single").enemyMoveset([MoveId.CHILLY_RECEPTION, MoveId.TACKLE]).moveset(MoveId.SPLASH);
|
|
|
|
|
|
|
|
|
|
expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.SNOW);
|
|
|
|
|
|
|
|
|
|
const slowking = game.scene.getPlayerPokemon()!;
|
|
|
|
|
|
|
|
|
|
game.move.select(MoveId.SNOWSCAPE);
|
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
|
|
|
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
|
|
|
|
|
|
|
|
game.move.select(MoveId.CHILLY_RECEPTION);
|
|
|
|
|
game.doSelectPartyPokemon(1);
|
|
|
|
|
await game.toEndOfTurn();
|
|
|
|
|
|
|
|
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
|
|
|
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
|
|
|
|
|
expect(game.scene.getPlayerPokemon()).toBe(slowking);
|
|
|
|
|
expect(slowking.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
|
|
|
|
expect(game.textInterceptor.logs).toContain(
|
|
|
|
|
i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(slowking) }),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should succeed without message if called indirectly", async () => {
|
|
|
|
|
vi.spyOn(RandomMoveAttr.prototype, "getMoveOverride").mockReturnValue(MoveId.CHILLY_RECEPTION);
|
|
|
|
|
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
|
|
|
|
|
|
|
|
|
const [slowking, meowth] = game.scene.getPlayerParty();
|
|
|
|
|
|
|
|
|
|
game.move.select(MoveId.METRONOME);
|
|
|
|
|
game.doSelectPartyPokemon(1);
|
|
|
|
|
await game.toEndOfTurn();
|
|
|
|
|
|
|
|
|
|
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([MoveId.CHILLY_RECEPTION, MoveId.TACKLE]);
|
|
|
|
|
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
|
|
|
|
|
|
|
|
|
game.move.select(MoveId.SPLASH);
|
|
|
|
|
await game.move.selectEnemyMove(MoveId.TACKLE);
|
|
|
|
|
await game.toEndOfTurn();
|
|
|
|
|
|
|
|
|
|
expect(game.scene.arena.weather?.weatherType).toBeUndefined();
|
|
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
|
expect(game.scene.arena.weather?.weatherType).toBe(undefined);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("enemy trainer - expected behavior ", async () => {
|
|
|
|
|
game.override
|
|
|
|
|
.battleStyle("single")
|
|
|
|
|
.startingWave(8)
|
|
|
|
|
.enemyMoveset(MoveId.CHILLY_RECEPTION)
|
|
|
|
|
.enemySpecies(SpeciesId.MAGIKARP)
|
|
|
|
|
.moveset([MoveId.SPLASH, MoveId.THUNDERBOLT]);
|
|
|
|
|
|
|
|
|
|
await game.classicMode.startBattle([SpeciesId.JOLTEON]);
|
|
|
|
|
const RIVAL_MAGIKARP1 = game.scene.getEnemyPokemon()?.id;
|
|
|
|
|
|
|
|
|
|
game.move.select(MoveId.SPLASH);
|
|
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
|
|
|
expect(game.scene.getEnemyPokemon()?.id !== RIVAL_MAGIKARP1);
|
|
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to("TurnInitPhase", false);
|
|
|
|
|
game.move.select(MoveId.SPLASH);
|
|
|
|
|
|
|
|
|
|
// second chilly reception should still switch out
|
|
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
|
|
|
await game.phaseInterceptor.to("TurnInitPhase", false);
|
|
|
|
|
expect(game.scene.getEnemyPokemon()?.id === RIVAL_MAGIKARP1);
|
|
|
|
|
game.move.select(MoveId.THUNDERBOLT);
|
|
|
|
|
|
|
|
|
|
// enemy chilly recep move should fail: it's snowing and no option to switch out
|
|
|
|
|
// no crashing
|
|
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
|
|
|
await game.phaseInterceptor.to("TurnInitPhase", false);
|
|
|
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
|
|
|
game.move.select(MoveId.SPLASH);
|
|
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|