From 18703b00f60d6a877c0e83e20b37f62ea130d1d0 Mon Sep 17 00:00:00 2001 From: xsn34kzx Date: Sun, 1 Sep 2024 22:23:13 -0400 Subject: [PATCH] Address Multiple Messages for `ProtectStatAbAttr` --- src/data/ability.ts | 6 +++--- src/phases/stat-stage-change-phase.ts | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index ac7c21e8c12..857c0c88ef8 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -545,7 +545,7 @@ export class FieldPriorityMoveImmunityAbAttr extends PreDefendAbAttr { } export class PostStatStageChangeAbAttr extends AbAttr { - applyPostStatStageChange(pokemon: Pokemon, simulated: boolean, statsStagesChanged: BattleStat[], levelChanged: integer, selfTarget: boolean, args: any[]): boolean | Promise { + applyPostStatStageChange(pokemon: Pokemon, simulated: boolean, statsChanged: BattleStat[], stagesChanged: integer, selfTarget: boolean, args: any[]): boolean | Promise { return false; } } @@ -4611,12 +4611,12 @@ 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); + return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPreStatStageChange(pokemon, passive, simulated, stat, cancelled, args), args, false, simulated); } export function applyPostStatStageChangeAbAttrs(attrType: Constructor, pokemon: Pokemon, stats: BattleStat[], stages: integer, selfTarget: boolean, simulated: boolean = false, ...args: any[]): Promise { - return applyAbAttrsInternal(attrType, pokemon, (attr, passive) => attr.applyPostStatStageChange(pokemon, simulated, stats, stages, selfTarget, args), args); + return applyAbAttrsInternal(attrType, pokemon, (attr, _passive) => attr.applyPostStatStageChange(pokemon, simulated, stats, stages, selfTarget, args), args, false, simulated); } export function applyPreSetStatusAbAttrs(attrType: Constructor, diff --git a/src/phases/stat-stage-change-phase.ts b/src/phases/stat-stage-change-phase.ts index f011ee573c9..6036931b54c 100644 --- a/src/phases/stat-stage-change-phase.ts +++ b/src/phases/stat-stage-change-phase.ts @@ -42,15 +42,23 @@ export class StatStageChangePhase extends PokemonPhase { return this.end(); } + let simulate = false; + const filteredStats = this.stats.filter(stat => { const cancelled = new Utils.BooleanHolder(false); if (!this.selfTarget && this.stages < 0) { + // TODO: Include simulate boolean when tag applications can be simulated this.scene.arena.applyTagsForSide(MistTag, pokemon.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY, cancelled); } if (!cancelled.value && !this.selfTarget && this.stages < 0) { - applyPreStatStageChangeAbAttrs(ProtectStatAbAttr, pokemon, stat, cancelled); + applyPreStatStageChangeAbAttrs(ProtectStatAbAttr, pokemon, stat, cancelled, simulate); + } + + // If one stat stage decrease is cancelled, simulate the rest of the applications + if (cancelled.value) { + simulate = true; } return !cancelled.value;