From b4cc9d7892a7d8b548c857f3acca40d5cf5defba Mon Sep 17 00:00:00 2001 From: innerthunder <168692175+innerthunder@users.noreply.github.com> Date: Mon, 28 Oct 2024 06:02:10 -0700 Subject: [PATCH] [Hotfix] Fix crash when Mist would block a stat drop (#4746) * Fix crash when Mist would block a stat drop * Bump version * Bump version (again) --- package-lock.json | 4 +-- package.json | 2 +- src/data/arena-tag.ts | 1 + src/phases/stat-stage-change-phase.ts | 2 +- src/test/moves/mist.test.ts | 49 +++++++++++++++++++++++++++ 5 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 src/test/moves/mist.test.ts diff --git a/package-lock.json b/package-lock.json index 17108c86ba8..9e512884922 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pokemon-rogue-battle", - "version": "1.1.5", + "version": "1.1.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "pokemon-rogue-battle", - "version": "1.1.5", + "version": "1.1.6", "hasInstallScript": true, "dependencies": { "@material/material-color-utilities": "^0.2.7", diff --git a/package.json b/package.json index 657bf7a5cd4..f106fb1a773 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pokemon-rogue-battle", "private": true, - "version": "1.1.5", + "version": "1.1.6", "type": "module", "scripts": { "start": "vite", diff --git a/src/data/arena-tag.ts b/src/data/arena-tag.ts index d2c95b7ccdf..43de6e02dcb 100644 --- a/src/data/arena-tag.ts +++ b/src/data/arena-tag.ts @@ -126,6 +126,7 @@ export class MistTag extends ArenaTag { * Cancels the lowering of stats * @param arena the {@linkcode Arena} containing this effect * @param simulated `true` if the effect should be applied quietly + * @param attacker the {@linkcode Pokemon} using a move into this effect. * @param cancelled a {@linkcode BooleanHolder} whose value is set to `true` * to flag the stat reduction as cancelled * @returns `true` if a stat reduction was cancelled; `false` otherwise diff --git a/src/phases/stat-stage-change-phase.ts b/src/phases/stat-stage-change-phase.ts index 2d4b3ce6c6f..ce6ebea2442 100644 --- a/src/phases/stat-stage-change-phase.ts +++ b/src/phases/stat-stage-change-phase.ts @@ -65,7 +65,7 @@ export class StatStageChangePhase extends PokemonPhase { if (!this.selfTarget && stages.value < 0) { // TODO: add a reference to the source of the stat change to fix Infiltrator interaction - this.scene.arena.applyTagsForSide(MistTag, pokemon.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY, false, null, false, cancelled); + this.scene.arena.applyTagsForSide(MistTag, pokemon.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY, false, null, cancelled); } if (!cancelled.value && !this.selfTarget && stages.value < 0) { diff --git a/src/test/moves/mist.test.ts b/src/test/moves/mist.test.ts new file mode 100644 index 00000000000..cd338f79412 --- /dev/null +++ b/src/test/moves/mist.test.ts @@ -0,0 +1,49 @@ +import { Stat } from "#enums/stat"; +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, expect, it } from "vitest"; + +describe("Moves - Mist", () => { + 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.MIST, Moves.SPLASH ]) + .ability(Abilities.BALL_FETCH) + .battleType("double") + .disableCrits() + .enemySpecies(Species.SNORLAX) + .enemyAbility(Abilities.BALL_FETCH) + .enemyMoveset(Moves.GROWL); + }); + + it("should prevent the user's side from having stats lowered", async () => { + await game.classicMode.startBattle([ Species.MAGIKARP, Species.FEEBAS ]); + + const playerPokemon = game.scene.getPlayerField(); + + game.move.select(Moves.MIST, 0); + game.move.select(Moves.SPLASH, 1); + + await game.phaseInterceptor.to("BerryPhase"); + + playerPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(0)); + }); + + it.todo("should be ignored by opponents with Infiltrator"); +});