Fix stack overflow

pull/1/head
Flashfyre 2023-05-02 22:27:04 -04:00
parent c49bac094f
commit 5413fd5c9c
2 changed files with 20 additions and 15 deletions

View File

@ -341,7 +341,7 @@ export class BlockWeatherDamageAttr extends PreWeatherDamageAbAttr {
} }
export class SuppressWeatherEffectAbAttr extends PreWeatherEffectAbAttr { export class SuppressWeatherEffectAbAttr extends PreWeatherEffectAbAttr {
private affectsImmutable: boolean; public affectsImmutable: boolean;
constructor(affectsImmutable?: boolean) { constructor(affectsImmutable?: boolean) {
super(); super();
@ -565,7 +565,7 @@ export function applyPreStatChangeAbAttrs(attrType: { new(...args: any[]): PreSt
} }
export function applyPreWeatherEffectAbAttrs(attrType: { new(...args: any[]): PreWeatherEffectAbAttr }, 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()) if (!pokemon.canApplyAbility())
return; return;
@ -576,12 +576,10 @@ export function applyPreWeatherEffectAbAttrs(attrType: { new(...args: any[]): Pr
continue; continue;
pokemon.scene.setPhaseQueueSplice(); pokemon.scene.setPhaseQueueSplice();
if (attr.applyPreWeatherEffect(pokemon, weather, cancelled, args)) { if (attr.applyPreWeatherEffect(pokemon, weather, cancelled, args)) {
if (!silent) { pokemon.scene.abilityBar.showAbility(pokemon);
pokemon.scene.abilityBar.showAbility(pokemon); const message = attr.getTriggerMessage(pokemon, weather);
const message = attr.getTriggerMessage(pokemon, weather); if (message)
if (message) pokemon.scene.queueMessage(message);
pokemon.scene.queueMessage(message);
}
} }
} }
@ -616,6 +614,9 @@ export function applyPostWeatherLapseAbAttrs(attrType: { new(...args: any[]): Po
if (!pokemon.canApplyAbility()) if (!pokemon.canApplyAbility())
return; return;
if (weather.isEffectSuppressed(pokemon.scene))
return;
const ability = pokemon.getAbility(); const ability = pokemon.getAbility();
const attrs = ability.getAttrs(attrType) as PostWeatherLapseAbAttr[]; const attrs = ability.getAttrs(attrType) as PostWeatherLapseAbAttr[];

View File

@ -103,15 +103,19 @@ export class Weather {
const playerPokemon = scene.getPlayerPokemon(); const playerPokemon = scene.getPlayerPokemon();
const enemyPokemon = scene.getEnemyPokemon(); 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) if (enemyPokemon) {
applyPreWeatherEffectAbAttrs(SuppressWeatherEffectAbAttr, playerPokemon, this, cancelled, true); const suppressWeatherEffectAbAttr = enemyPokemon.getAbility().getAttrs(SuppressWeatherEffectAbAttr).find(() => true) as SuppressWeatherEffectAbAttr;
if (suppressWeatherEffectAbAttr && (!this.isImmutable() || suppressWeatherEffectAbAttr.affectsImmutable))
return true;
}
if (enemyPokemon) return false;
applyPreWeatherEffectAbAttrs(SuppressWeatherEffectAbAttr, enemyPokemon, this, cancelled, true);
return cancelled.value;
} }
} }