Skip to content

Commit

Permalink
Address Multiple Messages for ProtectStatAbAttr
Browse files Browse the repository at this point in the history
  • Loading branch information
xsn34kzx committed Sep 2, 2024
1 parent 1d5a643 commit 18703b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/data/ability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean> {
applyPostStatStageChange(pokemon: Pokemon, simulated: boolean, statsChanged: BattleStat[], stagesChanged: integer, selfTarget: boolean, args: any[]): boolean | Promise<boolean> {
return false;
}
}
Expand Down Expand Up @@ -4611,12 +4611,12 @@ export function applyPreSwitchOutAbAttrs(attrType: Constructor<PreSwitchOutAbAtt

export function applyPreStatStageChangeAbAttrs(attrType: Constructor<PreStatStageChangeAbAttr>,
pokemon: Pokemon | null, stat: BattleStat, cancelled: Utils.BooleanHolder, simulated: boolean = false, ...args: any[]): Promise<void> {
return applyAbAttrsInternal<PreStatStageChangeAbAttr>(attrType, pokemon, (attr, passive) => attr.applyPreStatStageChange(pokemon, passive, simulated, stat, cancelled, args), args);
return applyAbAttrsInternal<PreStatStageChangeAbAttr>(attrType, pokemon, (attr, passive) => attr.applyPreStatStageChange(pokemon, passive, simulated, stat, cancelled, args), args, false, simulated);
}

export function applyPostStatStageChangeAbAttrs(attrType: Constructor<PostStatStageChangeAbAttr>,
pokemon: Pokemon, stats: BattleStat[], stages: integer, selfTarget: boolean, simulated: boolean = false, ...args: any[]): Promise<void> {
return applyAbAttrsInternal<PostStatStageChangeAbAttr>(attrType, pokemon, (attr, passive) => attr.applyPostStatStageChange(pokemon, simulated, stats, stages, selfTarget, args), args);
return applyAbAttrsInternal<PostStatStageChangeAbAttr>(attrType, pokemon, (attr, _passive) => attr.applyPostStatStageChange(pokemon, simulated, stats, stages, selfTarget, args), args, false, simulated);
}

export function applyPreSetStatusAbAttrs(attrType: Constructor<PreSetStatusAbAttr>,
Expand Down
10 changes: 9 additions & 1 deletion src/phases/stat-stage-change-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 18703b0

Please sign in to comment.