Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Hotfix] Fix crash when Mist would block a stat drop #4746

Merged
merged 4 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pokemon-rogue-battle",
"private": true,
"version": "1.1.5",
"version": "1.1.6",
"type": "module",
"scripts": {
"start": "vite",
Expand Down
1 change: 1 addition & 0 deletions src/data/arena-tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/phases/stat-stage-change-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
49 changes: 49 additions & 0 deletions src/test/moves/mist.test.ts
Original file line number Diff line number Diff line change
@@ -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");
});
Loading