From 01938dcf8335e76165c4cc54a73662ee72389a53 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 27 Feb 2024 14:21:17 -0500 Subject: [PATCH] Fix issue with skipped move charge effects not activating --- src/data/move.ts | 13 ++++++++++--- src/phases.ts | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 6cf646fb769..27f46d840ec 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -915,7 +915,7 @@ export class ChargeAttr extends OverrideMoveEffectAttr { public chargeAnim: ChargeAnim; private chargeText: string; private tagType: BattlerTagType; - public chargeEffect: boolean; + private chargeEffect: boolean; public sameTurn: boolean; public followUpPriority: integer; @@ -932,8 +932,8 @@ export class ChargeAttr extends OverrideMoveEffectAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise { return new Promise(resolve => { - const lastMove = user.getLastXMoves() as TurnMove[]; - if (!lastMove.length || lastMove[0].move !== move.id || lastMove[0].result !== MoveResult.OTHER) { + const lastMove = user.getLastXMoves().find(() => true); + if (!lastMove || lastMove.move !== move.id || lastMove.result !== MoveResult.OTHER) { (args[0] as Utils.BooleanHolder).value = true; new MoveChargeAnim(this.chargeAnim, move.id, user).play(user.scene, () => { user.scene.queueMessage(getPokemonMessage(user, ` ${this.chargeText.replace('{TARGET}', target.name)}`)); @@ -951,6 +951,13 @@ export class ChargeAttr extends OverrideMoveEffectAttr { resolve(false); }); } + + usedChargeEffect(user: Pokemon, target: Pokemon, move: Move): boolean { + if (!this.chargeEffect) + return false; + const lastMove = user.getLastXMoves().find(() => true); + return lastMove && lastMove.move === move.id && lastMove.result === MoveResult.OTHER; + } } export class SolarBeamChargeAttr extends ChargeAttr { diff --git a/src/phases.ts b/src/phases.ts index e8482fda28d..aacdf2fe60a 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2075,7 +2075,7 @@ export class MoveEffectPhase extends PokemonPhase { applyFilteredMoveAttrs((attr: MoveAttr) => attr instanceof MoveEffectAttr && (attr as MoveEffectAttr).trigger === MoveEffectTrigger.PRE_APPLY, user, target, this.move.getMove()).then(() => { if (hitResult !== HitResult.FAIL) { - const chargeEffect = !!this.move.getMove().getAttrs(ChargeAttr).find(ca => (ca as ChargeAttr).chargeEffect); + const chargeEffect = !!this.move.getMove().getAttrs(ChargeAttr).find(ca => (ca as ChargeAttr).usedChargeEffect(user, this.getTarget(), this.move.getMove())); // Charge attribute with charge effect takes all effect attributes and applies them to charge stage, so ignore them if this is present Utils.executeIf(!chargeEffect, () => applyFilteredMoveAttrs((attr: MoveAttr) => attr instanceof MoveEffectAttr && (attr as MoveEffectAttr).trigger === MoveEffectTrigger.POST_APPLY && (attr as MoveEffectAttr).selfTarget, user, target, this.move.getMove())).then(() => {