mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-01 05:52:17 +02:00
Fixed Chilly Reception displaying message when used virtually
This commit is contained in:
parent
4f8aae31b5
commit
0a5f24ba0d
@ -1350,18 +1350,27 @@ export class BeakBlastHeaderAttr extends AddBattlerTagHeaderAttr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute to display a message before a move is executed.
|
||||||
|
*/
|
||||||
export class PreMoveMessageAttr extends MoveAttr {
|
export class PreMoveMessageAttr extends MoveAttr {
|
||||||
private message: string | ((user: Pokemon, target: Pokemon, move: Move) => string);
|
/** The message to display or a function returning one */
|
||||||
|
private message: string | undefined | ((user: Pokemon, target: Pokemon, move: Move) => string | undefined);
|
||||||
|
|
||||||
constructor(message: string | ((user: Pokemon, target: Pokemon, move: Move) => string)) {
|
/**
|
||||||
|
* Create a new {@linkcode PreMoveMessageAttr} to display a message before move execution.
|
||||||
|
* @param message - The message to display before move use, either as a string or a function producing one.
|
||||||
|
* A value of `undefined` or an empty string (`''`) will cause no message to be displayed.
|
||||||
|
*/
|
||||||
|
constructor(message: string | undefined | ((user: Pokemon, target: Pokemon, move: Move) => string | undefined)) {
|
||||||
super();
|
super();
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
apply(user: Pokemon, target: Pokemon, move: Move, _args: any[]): boolean {
|
||||||
const message = typeof this.message === "string"
|
const message = typeof this.message === "function"
|
||||||
? this.message as string
|
? this.message(user, target, move)
|
||||||
: this.message(user, target, move);
|
: this.message;
|
||||||
if (message) {
|
if (message) {
|
||||||
globalScene.queueMessage(message, 500);
|
globalScene.queueMessage(message, 500);
|
||||||
return true;
|
return true;
|
||||||
@ -11120,7 +11129,12 @@ export function initMoves() {
|
|||||||
.attr(ForceSwitchOutAttr, true, SwitchType.SHED_TAIL)
|
.attr(ForceSwitchOutAttr, true, SwitchType.SHED_TAIL)
|
||||||
.condition(failIfLastInPartyCondition),
|
.condition(failIfLastInPartyCondition),
|
||||||
new SelfStatusMove(Moves.CHILLY_RECEPTION, PokemonType.ICE, -1, 10, -1, 0, 9)
|
new SelfStatusMove(Moves.CHILLY_RECEPTION, PokemonType.ICE, -1, 10, -1, 0, 9)
|
||||||
.attr(PreMoveMessageAttr, (user, move) => i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(user) }))
|
.attr(PreMoveMessageAttr, (user, _target, _move) =>
|
||||||
|
// Don't display text if current move phase is follow up (ie move called indirectly)
|
||||||
|
// TODO: Change in move-use-type PR to use the move phase's current use type
|
||||||
|
(globalScene.getCurrentPhase() as MovePhase)["followUp"]
|
||||||
|
? undefined
|
||||||
|
: i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(user) }))
|
||||||
.attr(ChillyReceptionAttr, true),
|
.attr(ChillyReceptionAttr, true),
|
||||||
new SelfStatusMove(Moves.TIDY_UP, PokemonType.NORMAL, -1, 10, -1, 0, 9)
|
new SelfStatusMove(Moves.TIDY_UP, PokemonType.NORMAL, -1, 10, -1, 0, 9)
|
||||||
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPD ], 1, true)
|
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPD ], 1, true)
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
|
import { RandomMoveAttr } from "#app/data/moves/move";
|
||||||
import { Abilities } from "#app/enums/abilities";
|
import { Abilities } from "#app/enums/abilities";
|
||||||
|
import { MoveResult } from "#app/field/pokemon";
|
||||||
|
import { getPokemonNameWithAffix } from "#app/messages";
|
||||||
import { Moves } from "#enums/moves";
|
import { Moves } from "#enums/moves";
|
||||||
import { Species } from "#enums/species";
|
import { Species } from "#enums/species";
|
||||||
import { WeatherType } from "#enums/weather-type";
|
import { WeatherType } from "#enums/weather-type";
|
||||||
import GameManager from "#test/testUtils/gameManager";
|
import GameManager from "#test/testUtils/gameManager";
|
||||||
|
import i18next from "i18next";
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
//import { TurnInitPhase } from "#app/phases/turn-init-phase";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
||||||
|
|
||||||
describe("Moves - Chilly Reception", () => {
|
describe("Moves - Chilly Reception", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
@ -25,98 +28,112 @@ describe("Moves - Chilly Reception", () => {
|
|||||||
game = new GameManager(phaserGame);
|
game = new GameManager(phaserGame);
|
||||||
game.override
|
game.override
|
||||||
.battleStyle("single")
|
.battleStyle("single")
|
||||||
.moveset([Moves.CHILLY_RECEPTION, Moves.SNOWSCAPE])
|
.moveset([Moves.CHILLY_RECEPTION, Moves.SNOWSCAPE, Moves.SPLASH, Moves.METRONOME])
|
||||||
.enemyMoveset(Array(4).fill(Moves.SPLASH))
|
.enemyMoveset(Moves.SPLASH)
|
||||||
.enemyAbility(Abilities.BALL_FETCH)
|
.enemyAbility(Abilities.BALL_FETCH)
|
||||||
.ability(Abilities.BALL_FETCH);
|
.ability(Abilities.BALL_FETCH);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should still change the weather if user can't switch out", async () => {
|
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]);
|
await game.classicMode.startBattle([Species.SLOWKING]);
|
||||||
|
|
||||||
game.move.select(Moves.CHILLY_RECEPTION);
|
game.move.select(Moves.CHILLY_RECEPTION);
|
||||||
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
await game.phaseInterceptor.to("BerryPhase", false);
|
||||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
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 switch out even if it's snowing", async () => {
|
it("should still switch out even if weather cannot be changed", async () => {
|
||||||
await game.classicMode.startBattle([Species.SLOWKING, Species.MEOWTH]);
|
await game.classicMode.startBattle([Species.SLOWKING, Species.MEOWTH]);
|
||||||
// first turn set up snow with snowscape, try chilly reception on second turn
|
|
||||||
|
expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.SNOW);
|
||||||
|
|
||||||
|
const [slowking, meowth] = game.scene.getPlayerParty();
|
||||||
|
|
||||||
game.move.select(Moves.SNOWSCAPE);
|
game.move.select(Moves.SNOWSCAPE);
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
await game.toNextTurn();
|
||||||
|
|
||||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||||
|
|
||||||
await game.phaseInterceptor.to("TurnInitPhase", false);
|
|
||||||
game.move.select(Moves.CHILLY_RECEPTION);
|
game.move.select(Moves.CHILLY_RECEPTION);
|
||||||
game.doSelectPartyPokemon(1);
|
game.doSelectPartyPokemon(1);
|
||||||
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
await game.phaseInterceptor.to("BerryPhase", false);
|
||||||
|
|
||||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||||
expect(game.scene.getPlayerField()[0].species.speciesId).toBe(Species.MEOWTH);
|
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
||||||
|
expect(game.scene.getPlayerPokemon()).toBe(meowth);
|
||||||
|
expect(slowking.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("happy case - switch out and weather changes", async () => {
|
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]);
|
await game.classicMode.startBattle([Species.SLOWKING, Species.MEOWTH]);
|
||||||
|
|
||||||
game.move.select(Moves.CHILLY_RECEPTION);
|
const [slowking, meowth] = game.scene.getPlayerParty();
|
||||||
game.doSelectPartyPokemon(1);
|
|
||||||
|
|
||||||
|
game.move.select(Moves.METRONOME);
|
||||||
|
game.doSelectPartyPokemon(1);
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
await game.phaseInterceptor.to("BerryPhase", false);
|
||||||
|
|
||||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||||
expect(game.scene.getPlayerField()[0].species.speciesId).toBe(Species.MEOWTH);
|
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) }),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// enemy uses another move and weather doesn't change
|
// Bugcheck test for enemy AI bug
|
||||||
it("check case - enemy not selecting chilly reception doesn't change weather ", async () => {
|
it("check case - enemy not selecting chilly reception doesn't change weather", async () => {
|
||||||
game.override
|
game.override.enemyMoveset([Moves.CHILLY_RECEPTION, Moves.TACKLE]);
|
||||||
.battleStyle("single")
|
|
||||||
.enemyMoveset([Moves.CHILLY_RECEPTION, Moves.TACKLE])
|
|
||||||
.moveset(Array(4).fill(Moves.SPLASH));
|
|
||||||
|
|
||||||
await game.classicMode.startBattle([Species.SLOWKING, Species.MEOWTH]);
|
await game.classicMode.startBattle([Species.SLOWKING, Species.MEOWTH]);
|
||||||
|
|
||||||
game.move.select(Moves.SPLASH);
|
game.move.select(Moves.SPLASH);
|
||||||
await game.forceEnemyMove(Moves.TACKLE);
|
await game.forceEnemyMove(Moves.TACKLE);
|
||||||
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
await game.phaseInterceptor.to("BerryPhase", false);
|
||||||
expect(game.scene.arena.weather?.weatherType).toBe(undefined);
|
expect(game.scene.arena.weather?.weatherType).toBeUndefined();
|
||||||
});
|
|
||||||
|
|
||||||
it("enemy trainer - expected behavior ", async () => {
|
|
||||||
game.override
|
|
||||||
.battleStyle("single")
|
|
||||||
.startingWave(8)
|
|
||||||
.enemyMoveset(Array(4).fill(Moves.CHILLY_RECEPTION))
|
|
||||||
.enemySpecies(Species.MAGIKARP)
|
|
||||||
.moveset([Moves.SPLASH, Moves.THUNDERBOLT]);
|
|
||||||
|
|
||||||
await game.classicMode.startBattle([Species.JOLTEON]);
|
|
||||||
const RIVAL_MAGIKARP1 = game.scene.getEnemyPokemon()?.id;
|
|
||||||
|
|
||||||
game.move.select(Moves.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(Moves.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(Moves.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(Moves.SPLASH);
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
|
||||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user