Fix mold breaker pp bug

This commit is contained in:
Sirz Benjie 2025-02-06 22:59:01 -06:00
parent b364bb1899
commit 4faace9b63
No known key found for this signature in database
GPG Key ID: 4A524B4D196C759E
3 changed files with 60 additions and 4 deletions

View File

@ -1,13 +1,20 @@
import { globalScene } from "#app/global-scene"; import { globalScene } from "#app/global-scene";
import { BattlerTagLapseType } from "#app/data/battler-tags"; import { BattlerTagLapseType } from "#app/data/battler-tags";
import { PokemonPhase } from "./pokemon-phase"; import { PokemonPhase } from "./pokemon-phase";
import type { BattlerIndex } from "#app/battle";
export class MoveEndPhase extends PokemonPhase { export class MoveEndPhase extends PokemonPhase {
private wasFollowUp: boolean;
constructor(battlerIndex: BattlerIndex, wasFollowUp: boolean = false) {
super(battlerIndex);
this.wasFollowUp = wasFollowUp;
}
start() { start() {
super.start(); super.start();
const pokemon = this.getPokemon(); const pokemon = this.getPokemon();
if (pokemon.isActive(true)) { if (!this.wasFollowUp && pokemon.isActive(true)) {
pokemon.lapseTags(BattlerTagLapseType.AFTER_MOVE); pokemon.lapseTags(BattlerTagLapseType.AFTER_MOVE);
} }

View File

@ -469,9 +469,7 @@ export class MovePhase extends BattlePhase {
* then ends the phase. * then ends the phase.
*/ */
public end(): void { public end(): void {
if (!this.followUp && this.canMove()) { globalScene.unshiftPhase(new MoveEndPhase(this.pokemon.getBattlerIndex(), this.followUp));
globalScene.unshiftPhase(new MoveEndPhase(this.pokemon.getBattlerIndex()));
}
super.end(); super.end();
} }

View File

@ -0,0 +1,51 @@
import { BattlerIndex } from "#app/battle";
import { globalScene } from "#app/global-scene";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/testUtils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Abilities - Mold Breaker", () => {
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.SPLASH ])
.ability(Abilities.MOLD_BREAKER)
.battleType("single")
.disableCrits()
.enemySpecies(Species.MAGIKARP)
.enemyAbility(Abilities.BALL_FETCH)
.enemyMoveset(Moves.SPLASH);
});
it("should turn off the ignore abilities arena variable after the user's move", async () => {
game.override.enemyMoveset(Moves.SPLASH)
.ability(Abilities.MOLD_BREAKER)
.moveset([ Moves.ERUPTION ])
.startingLevel(100)
.enemyLevel(2);
await game.classicMode.startBattle([ Species.MAGIKARP ]);
const enemy = game.scene.getEnemyPokemon()!;
expect(enemy.isFainted()).toBe(false);
game.move.select(Moves.SPLASH);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to("MoveEndPhase", true);
expect(globalScene.arena.ignoreAbilities).toBe(false);
});
});