Fix issue with skipped move charge effects not activating

This commit is contained in:
Flashfyre 2024-02-27 14:21:17 -05:00
parent 143c38d0bd
commit 01938dcf83
2 changed files with 11 additions and 4 deletions

View File

@ -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<boolean> {
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 {

View File

@ -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(() => {