From be6000f59067509b6ad90b5d1ca7d615223fe886 Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Sun, 8 Jun 2025 09:53:10 -0400 Subject: [PATCH] Fixed phasemanager bugs --- src/data/battler-tags.ts | 17 +++++++++++++---- src/phases/move-effect-phase.ts | 10 +++++----- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 44637ffb5e7..4f9077a0fc0 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -1036,8 +1036,11 @@ export class PowderTag extends BattlerTag { movePhase.showMoveText(); movePhase.fail(); - globalScene.unshiftPhase( - new CommonAnimPhase(pokemon.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.POWDER), + globalScene.phaseManager.unshiftNew( + "CommonAnimPhase", + pokemon.getBattlerIndex(), + pokemon.getBattlerIndex(), + CommonAnim.POWDER, ); const cancelDamage = new BooleanHolder(false); @@ -1047,7 +1050,7 @@ export class PowderTag extends BattlerTag { } // "When the flame touched the powder\non the Pokémon, it exploded!" - globalScene.queueMessage(i18next.t("battlerTags:powderLapse", { moveName: move.name })); + globalScene.phaseManager.queueMessage(i18next.t("battlerTags:powderLapse", { moveName: move.name })); return true; } @@ -1175,7 +1178,13 @@ export class EncoreTag extends MoveRestrictionBattlerTag { const lastMove = pokemon.getLastXMoves(1)[0]; globalScene.phaseManager.tryReplacePhase( m => m.is("MovePhase") && m.pokemon === pokemon, - globalScene.phaseManager.create("MovePhase", pokemon, lastMove.targets ?? [], movesetMove, MoveUseMode.NORMAL), + globalScene.phaseManager.create( + "MovePhase", + pokemon, + lastMove.targets ?? [], + movesetMove, + MoveUseMode.NORMAL, + ), ); } } diff --git a/src/phases/move-effect-phase.ts b/src/phases/move-effect-phase.ts index 560d92a0eed..13319c043d1 100644 --- a/src/phases/move-effect-phase.ts +++ b/src/phases/move-effect-phase.ts @@ -206,7 +206,7 @@ export class MoveEffectPhase extends PokemonPhase { "MovePhase", target, newTargets, - new PokemonMove(this.move.id, 0, 0, true), + new PokemonMove(this.move.id), MoveUseMode.REFLECTED, ), ); @@ -427,7 +427,7 @@ export class MoveEffectPhase extends PokemonPhase { * unshift another MoveEffectPhase for the next strike before ending this phase. */ if (--user.turnData.hitsLeft >= 1 && this.getFirstTarget()) { - globalScene.phaseManager.unshiftPhase(this.addNextHitPhase()); + this.addNextHitPhase(); super.end(); return; } @@ -439,7 +439,7 @@ export class MoveEffectPhase extends PokemonPhase { const hitsTotal = user.turnData.hitCount - Math.max(user.turnData.hitsLeft, 0); if (hitsTotal > 1 || user.turnData.hitsLeft > 0) { // Queue message if multiple hits occurred or were slated to occur (such as a Triple Axel miss) - globalScene.queueMessage(i18next.t("battle:attackHitsCount", { count: hitsTotal })); + globalScene.phaseManager.queueMessage(i18next.t("battle:attackHitsCount", { count: hitsTotal })); } globalScene.applyModifiers(HitHealModifier, this.player, user); @@ -741,8 +741,8 @@ export class MoveEffectPhase extends PokemonPhase { } /** - * Unshifts a new `MoveEffectPhase` with the same properties as this phase, - * except with 1 fewer hit remaining + * Unshifts a new `MoveEffectPhase` with the same properties as this phase. + * Used to queue the next hit of multi-strike moves. */ protected addNextHitPhase(): void { globalScene.phaseManager.unshiftNew("MoveEffectPhase", this.battlerIndex, this.targets, this.move, this.useMode);