Fix issue with skipped move charge effects not activating

pull/16/head
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; public chargeAnim: ChargeAnim;
private chargeText: string; private chargeText: string;
private tagType: BattlerTagType; private tagType: BattlerTagType;
public chargeEffect: boolean; private chargeEffect: boolean;
public sameTurn: boolean; public sameTurn: boolean;
public followUpPriority: integer; public followUpPriority: integer;
@ -932,8 +932,8 @@ export class ChargeAttr extends OverrideMoveEffectAttr {
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
return new Promise(resolve => { return new Promise(resolve => {
const lastMove = user.getLastXMoves() as TurnMove[]; const lastMove = user.getLastXMoves().find(() => true);
if (!lastMove.length || lastMove[0].move !== move.id || lastMove[0].result !== MoveResult.OTHER) { if (!lastMove || lastMove.move !== move.id || lastMove.result !== MoveResult.OTHER) {
(args[0] as Utils.BooleanHolder).value = true; (args[0] as Utils.BooleanHolder).value = true;
new MoveChargeAnim(this.chargeAnim, move.id, user).play(user.scene, () => { new MoveChargeAnim(this.chargeAnim, move.id, user).play(user.scene, () => {
user.scene.queueMessage(getPokemonMessage(user, ` ${this.chargeText.replace('{TARGET}', target.name)}`)); user.scene.queueMessage(getPokemonMessage(user, ` ${this.chargeText.replace('{TARGET}', target.name)}`));
@ -951,6 +951,13 @@ export class ChargeAttr extends OverrideMoveEffectAttr {
resolve(false); 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 { 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, applyFilteredMoveAttrs((attr: MoveAttr) => attr instanceof MoveEffectAttr && (attr as MoveEffectAttr).trigger === MoveEffectTrigger.PRE_APPLY,
user, target, this.move.getMove()).then(() => { user, target, this.move.getMove()).then(() => {
if (hitResult !== HitResult.FAIL) { 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 // 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 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(() => { && (attr as MoveEffectAttr).selfTarget, user, target, this.move.getMove())).then(() => {