Fix weather suppression abilities suppressing weather while ending

Fixes a few issues with protosynthesis as well.
This commit is contained in:
Andrew Werner
2024-03-15 22:33:32 -04:00
parent 4e1b3de4b1
commit c2a033ba1e
3 changed files with 41 additions and 8 deletions

View File

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

View File

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

View File

@@ -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 () {