Skip to content

Commit c2a033b

Browse files
committed
Fix weather suppression abilities suppressing weather while ending
Fixes a few issues with protosynthesis as well.
1 parent 4e1b3de commit c2a033b

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

data/abilities.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export const Abilities: {[abilityid: string]: AbilityData} = {
100100
this.eachEvent('WeatherChange', this.effect);
101101
},
102102
onEnd(pokemon) {
103+
pokemon.abilityState.ending = true;
103104
this.eachEvent('WeatherChange', this.effect);
104105
},
105106
suppressWeather: true,
@@ -544,6 +545,7 @@ export const Abilities: {[abilityid: string]: AbilityData} = {
544545
this.eachEvent('WeatherChange', this.effect);
545546
},
546547
onEnd(pokemon) {
548+
pokemon.abilityState.ending = true;
547549
this.eachEvent('WeatherChange', this.effect);
548550
},
549551
suppressWeather: true,
@@ -3420,11 +3422,11 @@ export const Abilities: {[abilityid: string]: AbilityData} = {
34203422
this.singleEvent('WeatherChange', this.effect, this.effectState, pokemon);
34213423
},
34223424
onWeatherChange(pokemon) {
3423-
// Protosynthesis is not affected by Utility Umbrella, or any weather supressing ability
3424-
// As a result, we check the weather directly instead of via field#isWeather which calls field#effectiveWeather
3425-
if (this.field.weather === 'sunnyday') {
3425+
// Protosynthesis is not affected by Utility Umbrella
3426+
if (this.field.isWeather('sunnyday')) {
34263427
pokemon.addVolatile('protosynthesis');
3427-
} else if (!pokemon.volatiles['protosynthesis']?.fromBooster) {
3428+
} else if (!pokemon.volatiles['protosynthesis']?.fromBooster && this.field.weather !== 'sunnyday') {
3429+
// Protosynthesis will not deactivite if Sun is suppressed, hence the direct ID check (isWeather respects supression)
34283430
pokemon.removeVolatile('protosynthesis');
34293431
}
34303432
},

sim/field.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ export class Field {
106106
suppressingWeather() {
107107
for (const side of this.battle.sides) {
108108
for (const pokemon of side.active) {
109-
if (pokemon && !pokemon.fainted && !pokemon.ignoringAbility() && pokemon.getAbility().suppressWeather) {
109+
if (pokemon && !pokemon.fainted && !pokemon.ignoringAbility() &&
110+
pokemon.getAbility().suppressWeather && !pokemon.abilityState.ending) {
110111
return true;
111112
}
112113
}

test/sim/abilities/protosynthesis.js

+33-3
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,46 @@ describe('Protosynthesis', function () {
7777
assert.equal(tail.volatiles['protosynthesis'].bestStat, 'spd', `Scream Tail's SpD should have been boosted by Protosynthesis in Sun while holding Utility Umbrella`);
7878
});
7979

80-
it(`should not be prevented from activating by weather suppressing abilities`, function () {
80+
it(`should not be deactiviated by weather suppressing abilities`, function () {
8181
battle = common.createBattle([[
8282
{species: 'Scream Tail', ability: 'protosynthesis', moves: ['splash']},
8383
], [
84-
{species: 'Altaria', ability: 'cloudnine', moves: ['sunnyday']},
84+
{species: 'Torkoal', ability: 'drought', moves: ['splash']},
85+
{species: 'Psyduck', ability: 'cloudnine', moves: ['splash']},
86+
]]);
87+
88+
const tail = battle.p1.active[0];
89+
battle.makeChoices('move splash', 'switch 2');
90+
91+
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`);
92+
});
93+
94+
it(`should not activate if weather is suppressed`, function () {
95+
battle = common.createBattle([[
96+
{species: 'Scream Tail', ability: 'protosynthesis', moves: ['splash']},
97+
], [
98+
{species: 'Psyduck', ability: 'cloudnine', moves: ['sunnyday']},
99+
]]);
100+
101+
const tail = battle.p1.active[0];
102+
battle.makeChoices('move splash', 'move sunnyday');
103+
104+
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`);
105+
});
106+
107+
it(`should activate when weather supression ends`, function () {
108+
battle = common.createBattle([[
109+
{species: 'Scream Tail', ability: 'protosynthesis', moves: ['splash']},
110+
], [
111+
{species: 'Psyduck', ability: 'cloudnine', moves: ['sunnyday']},
112+
{species: 'Lotad', ability: 'swiftswim', moves: ['splash']},
85113
]]);
86114

87115
const tail = battle.p1.active[0];
88116
battle.makeChoices('move splash', 'move sunnyday');
89-
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`);
117+
battle.makeChoices('move splash', 'switch 2');
118+
119+
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`);
90120
});
91121

92122
it(`should have its boost nullified by Neutralizing Gas`, function () {

0 commit comments

Comments
 (0)