Address Multiple Messages for ProtectStatAbAttr

This commit is contained in:
xsn34kzx 2024-09-01 22:23:13 -04:00
parent 1d5a643d1f
commit 18703b00f6
2 changed files with 12 additions and 4 deletions

View File

@ -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;
}
}
@ -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>,

View File

@ -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;