From 5413fd5c9cdc0e13480081a425e43d5dabe947b7 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 2 May 2023 22:27:04 -0400 Subject: [PATCH] Fix stack overflow --- src/data/ability.ts | 17 +++++++++-------- src/data/weather.ts | 18 +++++++++++------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 279833a32..2741d7a76 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -341,7 +341,7 @@ export class BlockWeatherDamageAttr extends PreWeatherDamageAbAttr { } export class SuppressWeatherEffectAbAttr extends PreWeatherEffectAbAttr { - private affectsImmutable: boolean; + public affectsImmutable: boolean; constructor(affectsImmutable?: boolean) { super(); @@ -565,7 +565,7 @@ export function applyPreStatChangeAbAttrs(attrType: { new(...args: any[]): PreSt } export function applyPreWeatherEffectAbAttrs(attrType: { new(...args: any[]): PreWeatherEffectAbAttr }, - pokemon: Pokemon, weather: Weather, cancelled: Utils.BooleanHolder, silent?: boolean, ...args: any[]): void { + pokemon: Pokemon, weather: Weather, cancelled: Utils.BooleanHolder, ...args: any[]): void { if (!pokemon.canApplyAbility()) return; @@ -576,12 +576,10 @@ export function applyPreWeatherEffectAbAttrs(attrType: { new(...args: any[]): Pr continue; pokemon.scene.setPhaseQueueSplice(); if (attr.applyPreWeatherEffect(pokemon, weather, cancelled, args)) { - if (!silent) { - pokemon.scene.abilityBar.showAbility(pokemon); - const message = attr.getTriggerMessage(pokemon, weather); - if (message) - pokemon.scene.queueMessage(message); - } + pokemon.scene.abilityBar.showAbility(pokemon); + const message = attr.getTriggerMessage(pokemon, weather); + if (message) + pokemon.scene.queueMessage(message); } } @@ -616,6 +614,9 @@ export function applyPostWeatherLapseAbAttrs(attrType: { new(...args: any[]): Po if (!pokemon.canApplyAbility()) return; + if (weather.isEffectSuppressed(pokemon.scene)) + return; + const ability = pokemon.getAbility(); const attrs = ability.getAttrs(attrType) as PostWeatherLapseAbAttr[]; diff --git a/src/data/weather.ts b/src/data/weather.ts index 2949b26fa..ca4bbf258 100644 --- a/src/data/weather.ts +++ b/src/data/weather.ts @@ -103,15 +103,19 @@ export class Weather { const playerPokemon = scene.getPlayerPokemon(); const enemyPokemon = scene.getEnemyPokemon(); - const cancelled = new Utils.BooleanHolder(false); + if (playerPokemon) { + const suppressWeatherEffectAbAttr = playerPokemon.getAbility().getAttrs(SuppressWeatherEffectAbAttr).find(() => true) as SuppressWeatherEffectAbAttr; + if (suppressWeatherEffectAbAttr && (!this.isImmutable() || suppressWeatherEffectAbAttr.affectsImmutable)) + return true; + } - if (playerPokemon) - applyPreWeatherEffectAbAttrs(SuppressWeatherEffectAbAttr, playerPokemon, this, cancelled, true); + if (enemyPokemon) { + const suppressWeatherEffectAbAttr = enemyPokemon.getAbility().getAttrs(SuppressWeatherEffectAbAttr).find(() => true) as SuppressWeatherEffectAbAttr; + if (suppressWeatherEffectAbAttr && (!this.isImmutable() || suppressWeatherEffectAbAttr.affectsImmutable)) + return true; + } - if (enemyPokemon) - applyPreWeatherEffectAbAttrs(SuppressWeatherEffectAbAttr, enemyPokemon, this, cancelled, true); - - return cancelled.value; + return false; } }