From fa00a744f1242f22ea98f3076432e12c9fd4cadd Mon Sep 17 00:00:00 2001 From: Dean Date: Sat, 1 Feb 2025 21:38:52 -0800 Subject: [PATCH] Update preStatStageChange --- src/data/ability.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 922d994375a..2cbca1e766f 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -2792,6 +2792,10 @@ export class PreSwitchOutFormChangeAbAttr extends PreSwitchOutAbAttr { } export class PreStatStageChangeAbAttr extends AbAttr { + willSucceedPreStatStageChange(pokemon: Pokemon | null, passive: boolean, simulated: boolean, stat: BattleStat, cancelled: Utils.BooleanHolder, args: any[]): boolean { + return true; + } + applyPreStatStageChange(pokemon: Pokemon | null, passive: boolean, simulated: boolean, stat: BattleStat, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise { return false; } @@ -2810,6 +2814,10 @@ export class ProtectStatAbAttr extends PreStatStageChangeAbAttr { this.protectedStat = protectedStat; } + willSucceedPreStatStageChange(pokemon: Pokemon | null, passive: boolean, simulated: boolean, stat: BattleStat, cancelled: Utils.BooleanHolder, args: any[]): boolean { + return Utils.isNullOrUndefined(this.protectedStat) || stat === this.protectedStat; + } + /** * Apply the {@linkcode ProtectedStatAbAttr} to an interaction * @param _pokemon @@ -2821,12 +2829,8 @@ export class ProtectStatAbAttr extends PreStatStageChangeAbAttr { * @returns true if the stat is protected, false otherwise */ applyPreStatStageChange(_pokemon: Pokemon, _passive: boolean, _simulated: boolean, stat: BattleStat, cancelled: Utils.BooleanHolder, _args: any[]): boolean { - if (Utils.isNullOrUndefined(this.protectedStat) || stat === this.protectedStat) { - cancelled.value = true; - return true; - } - - return false; + cancelled.value = true; + return true; } getTriggerMessage(pokemon: Pokemon, abilityName: string, ..._args: any[]): string { @@ -5322,7 +5326,8 @@ export function applyPreSwitchOutAbAttrs(attrType: Constructor, pokemon: Pokemon | null, stat: BattleStat, cancelled: Utils.BooleanHolder, simulated: boolean = false, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPreStatStageChange(pokemon, passive, simulated, stat, cancelled, args), args, false, simulated); + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPreStatStageChange(pokemon, passive, simulated, stat, cancelled, args), + (attr, passive) => attr.willSucceedPreStatStageChange(pokemon, passive, simulated, stat, cancelled, args), args, false, simulated); } export function applyPostStatStageChangeAbAttrs(attrType: Constructor,