diff --git a/data/abilities.ts b/data/abilities.ts index 4e1f52178f..cd27dfd684 100644 --- a/data/abilities.ts +++ b/data/abilities.ts @@ -100,6 +100,7 @@ export const Abilities: {[abilityid: string]: AbilityData} = { this.eachEvent('WeatherChange', this.effect); }, onEnd(pokemon) { + pokemon.abilityState.ending = true; this.eachEvent('WeatherChange', this.effect); }, suppressWeather: true, @@ -544,6 +545,7 @@ export const Abilities: {[abilityid: string]: AbilityData} = { this.eachEvent('WeatherChange', this.effect); }, onEnd(pokemon) { + pokemon.abilityState.ending = true; this.eachEvent('WeatherChange', this.effect); }, suppressWeather: true, @@ -3420,11 +3422,11 @@ export const Abilities: {[abilityid: string]: AbilityData} = { this.singleEvent('WeatherChange', this.effect, this.effectState, pokemon); }, onWeatherChange(pokemon) { - // Protosynthesis is not affected by Utility Umbrella, or any weather supressing ability - // As a result, we check the weather directly instead of via field#isWeather which calls field#effectiveWeather - if (this.field.weather === 'sunnyday') { + // Protosynthesis is not affected by Utility Umbrella + if (this.field.isWeather('sunnyday')) { pokemon.addVolatile('protosynthesis'); - } else if (!pokemon.volatiles['protosynthesis']?.fromBooster) { + } else if (!pokemon.volatiles['protosynthesis']?.fromBooster && this.field.weather !== 'sunnyday') { + // Protosynthesis will not deactivite if Sun is suppressed, hence the direct ID check (isWeather respects supression) pokemon.removeVolatile('protosynthesis'); } }, diff --git a/sim/field.ts b/sim/field.ts index 2e0e975b37..067c92d1b0 100644 --- a/sim/field.ts +++ b/sim/field.ts @@ -106,7 +106,8 @@ export class Field { suppressingWeather() { for (const side of this.battle.sides) { for (const pokemon of side.active) { - if (pokemon && !pokemon.fainted && !pokemon.ignoringAbility() && pokemon.getAbility().suppressWeather) { + if (pokemon && !pokemon.fainted && !pokemon.ignoringAbility() && + pokemon.getAbility().suppressWeather && !pokemon.abilityState.ending) { return true; } } diff --git a/test/sim/abilities/protosynthesis.js b/test/sim/abilities/protosynthesis.js index 32f0e9548f..4159c47ef8 100644 --- a/test/sim/abilities/protosynthesis.js +++ b/test/sim/abilities/protosynthesis.js @@ -77,16 +77,46 @@ describe('Protosynthesis', function () { assert.equal(tail.volatiles['protosynthesis'].bestStat, 'spd', `Scream Tail's SpD should have been boosted by Protosynthesis in Sun while holding Utility Umbrella`); }); - it(`should not be prevented from activating by weather suppressing abilities`, function () { + it(`should not be deactiviated by weather suppressing abilities`, function () { battle = common.createBattle([[ {species: 'Scream Tail', ability: 'protosynthesis', moves: ['splash']}, ], [ - {species: 'Altaria', ability: 'cloudnine', moves: ['sunnyday']}, + {species: 'Torkoal', ability: 'drought', moves: ['splash']}, + {species: 'Psyduck', ability: 'cloudnine', moves: ['splash']}, + ]]); + + const tail = battle.p1.active[0]; + battle.makeChoices('move splash', 'switch 2'); + + assert.equal(tail.volatiles['protosynthesis'].bestStat, 'spd', `Scream Tail's SpD should have remained boosted by Protosynthesis in Sun even though a weather supressing ability was activated`); + }); + + it(`should not activate if weather is suppressed`, function () { + battle = common.createBattle([[ + {species: 'Scream Tail', ability: 'protosynthesis', moves: ['splash']}, + ], [ + {species: 'Psyduck', ability: 'cloudnine', moves: ['sunnyday']}, ]]); const tail = battle.p1.active[0]; battle.makeChoices('move splash', 'move sunnyday'); - assert.equal(tail.volatiles['protosynthesis'].bestStat, 'spd', `Scream Tail's SpD should have been boosted by Protosynthesis in Sun even though a weather supressing ability was active`); + + assert.equal(tail.volatiles['protosynthesis'], undefined, `Scream Tail should not have been boosted by Protosynthesis because a weather supressing ability was active when Sun started`); + }); + + it(`should activate when weather supression ends`, function () { + battle = common.createBattle([[ + {species: 'Scream Tail', ability: 'protosynthesis', moves: ['splash']}, + ], [ + {species: 'Psyduck', ability: 'cloudnine', moves: ['sunnyday']}, + {species: 'Lotad', ability: 'swiftswim', moves: ['splash']}, + ]]); + + const tail = battle.p1.active[0]; + battle.makeChoices('move splash', 'move sunnyday'); + battle.makeChoices('move splash', 'switch 2'); + + assert.equal(tail.volatiles['protosynthesis'].bestStat, 'spd', `Scream Tail should have been boosted by Protosynthesis because a weather supressing ability ended while Sun was active`); }); it(`should have its boost nullified by Neutralizing Gas`, function () {