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

[Bug] Fix #5422 Neutralizing Gas and Legendary Weather Abilities Persist After Flee #5496

Open
wants to merge 3 commits into
base: beta
Choose a base branch
from
Open
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: 3 additions & 1 deletion src/phases/attempt-run-phase.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { applyAbAttrs, RunSuccessAbAttr } from "#app/data/ability";
import { applyAbAttrs, applyPreLeaveFieldAbAttrs, PreLeaveFieldAbAttr, RunSuccessAbAttr } from "#app/data/ability";
import { Stat } from "#app/enums/stat";
import { StatusEffect } from "#app/enums/status-effect";
import type { PlayerPokemon, EnemyPokemon } from "#app/field/pokemon";
Expand Down Expand Up @@ -29,6 +29,8 @@ export class AttemptRunPhase extends PokemonPhase {
applyAbAttrs(RunSuccessAbAttr, playerPokemon, null, false, escapeChance);

if (playerPokemon.randSeedInt(100) < escapeChance.value && !this.forceFailEscape) {
enemyField.forEach(enemyPokemon => applyPreLeaveFieldAbAttrs(PreLeaveFieldAbAttr, enemyPokemon));

globalScene.playSound("se/flee");
globalScene.queueMessage(i18next.t("battle:runAwaySuccess"), null, true, 500);

Expand Down
18 changes: 18 additions & 0 deletions test/abilities/desolate-land.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PokeballType } from "#app/enums/pokeball";
import { WeatherType } from "#app/enums/weather-type";
import type { CommandPhase } from "#app/phases/command-phase";
import { Command } from "#app/ui/command-ui-handler";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
Expand Down Expand Up @@ -131,4 +133,20 @@ describe("Abilities - Desolate Land", () => {

expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.HARSH_SUN);
});

it("should lift after fleeing from a wild pokemon", async () => {
game.override
.enemyAbility(Abilities.DESOLATE_LAND)
.ability(Abilities.BALL_FETCH);
await game.classicMode.startBattle([ Species.MAGIKARP ]);
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.HARSH_SUN);

vi.spyOn(game.scene.getPlayerPokemon()!, "randSeedInt").mockReturnValue(0);

const commandPhase = game.scene.getCurrentPhase() as CommandPhase;
commandPhase.handleCommand(Command.RUN, 0);
await game.phaseInterceptor.to("BerryPhase");

expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.HARSH_SUN);
});
});
20 changes: 19 additions & 1 deletion test/abilities/neutralizing_gas.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { BattlerIndex } from "#app/battle";
import type { CommandPhase } from "#app/phases/command-phase";
import { Command } from "#app/ui/command-ui-handler";
import { Abilities } from "#enums/abilities";
import { ArenaTagType } from "#enums/arena-tag-type";
import { Moves } from "#enums/moves";
Expand All @@ -7,7 +9,7 @@ import { Species } from "#enums/species";
import { Stat } from "#enums/stat";
import GameManager from "#test/testUtils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";

describe("Abilities - Neutralizing Gas", () => {
let phaserGame: Phaser.Game;
Expand Down Expand Up @@ -155,4 +157,20 @@ describe("Abilities - Neutralizing Gas", () => {

expect(game.scene.arena.getTag(ArenaTagType.NEUTRALIZING_GAS)).toBeUndefined();
});

it("should deactivate after fleeing from a wild pokemon", async () => {
game.override
.enemyAbility(Abilities.NEUTRALIZING_GAS)
.ability(Abilities.BALL_FETCH);
await game.classicMode.startBattle([ Species.MAGIKARP ]);
expect(game.scene.arena.getTag(ArenaTagType.NEUTRALIZING_GAS)).toBeDefined();

vi.spyOn(game.scene.getPlayerPokemon()!, "randSeedInt").mockReturnValue(0);

const commandPhase = game.scene.getCurrentPhase() as CommandPhase;
commandPhase.handleCommand(Command.RUN, 0);
await game.phaseInterceptor.to("BerryPhase");

expect(game.scene.arena.getTag(ArenaTagType.NEUTRALIZING_GAS)).toBeUndefined();
});
});