Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically activate Booster Energy during weather/terrain changes #10832

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions data/abilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ export const Abilities: import('../sim/dex-abilities').AbilityDataTable = {
},
onUpdate(pokemon) {
if (this.gameType !== 'doubles') return;
// don't run between when a Pokemon switches in and the resulting onSwitchIn event
// don't run between when a Pokemon switches in and the resulting SwitchIn event
if (this.queue.peek()?.choice === 'runSwitch') return;

const ally = pokemon.allies()[0];
Expand Down Expand Up @@ -3438,10 +3438,20 @@ export const Abilities: import('../sim/dex-abilities').AbilityDataTable = {
// Protosynthesis is not affected by Utility Umbrella
if (this.field.isWeather('sunnyday')) {
pokemon.addVolatile('protosynthesis');
} else if (!pokemon.volatiles['protosynthesis']?.fromBooster && !this.field.isWeather('sunnyday')) {
} else if (!pokemon.volatiles['protosynthesis'] && pokemon.hasItem('boosterenergy')) {
andrebastosdias marked this conversation as resolved.
Show resolved Hide resolved
pokemon.useItem();
andrebastosdias marked this conversation as resolved.
Show resolved Hide resolved
} else if (!pokemon.volatiles['protosynthesis']?.fromBooster) {
pokemon.removeVolatile('protosynthesis');
}
},
onUpdate(pokemon) {
// don't run between when a Pokemon switches in and the resulting SwitchIn event
if (this.queue.peek()?.choice === 'runSwitch') return;

if (!pokemon.volatiles['protosynthesis'] && !this.field.isWeather('sunnyday') && pokemon.hasItem('boosterenergy')) {
pokemon.useItem();
}
},
onEnd(pokemon) {
delete pokemon.volatiles['protosynthesis'];
this.add('-end', pokemon, 'Protosynthesis', '[silent]');
Expand Down Expand Up @@ -3574,10 +3584,20 @@ export const Abilities: import('../sim/dex-abilities').AbilityDataTable = {
onTerrainChange(pokemon) {
if (this.field.isTerrain('electricterrain')) {
pokemon.addVolatile('quarkdrive');
} else if (!pokemon.volatiles['quarkdrive'] && pokemon.hasItem('boosterenergy')) {
pokemon.useItem();
} else if (!pokemon.volatiles['quarkdrive']?.fromBooster) {
pokemon.removeVolatile('quarkdrive');
}
},
onUpdate(pokemon) {
// don't run between when a Pokemon switches in and the resulting SwitchIn event
if (this.queue.peek()?.choice === 'runSwitch') return;

if (!pokemon.volatiles['quarkdrive'] && !this.field.isTerrain('electricterrain') && pokemon.hasItem('boosterenergy')) {
pokemon.useItem();
}
},
onEnd(pokemon) {
delete pokemon.volatiles['quarkdrive'];
this.add('-end', pokemon, 'Quark Drive', '[silent]');
Expand Down
17 changes: 4 additions & 13 deletions data/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,20 +613,11 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
fling: {
basePower: 30,
},
onSwitchInPriority: -2,
onStart(pokemon) {
this.effectState.started = true;
((this.effect as any).onUpdate as (p: Pokemon) => void).call(this, pokemon);
onUseItem(item, pokemon) {
return ['protosynthesis', 'quarkdrive'].includes(pokemon.ability);
andrebastosdias marked this conversation as resolved.
Show resolved Hide resolved
},
onUpdate(pokemon) {
if (!this.effectState.started || pokemon.transformed) return;

if (pokemon.hasAbility('protosynthesis') && !this.field.isWeather('sunnyday') && pokemon.useItem()) {
pokemon.addVolatile('protosynthesis');
}
if (pokemon.hasAbility('quarkdrive') && !this.field.isTerrain('electricterrain') && pokemon.useItem()) {
pokemon.addVolatile('quarkdrive');
}
onUse(pokemon) {
pokemon.addVolatile(pokemon.ability);
},
onTakeItem(item, source) {
if (source.baseSpecies.tags.includes("Paradox")) return false;
Expand Down
2 changes: 2 additions & 0 deletions data/mods/gen9dlc1/abilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export const Abilities: import('../../../sim/dex-abilities').ModdedAbilityDataTa
// Protosynthesis is not affected by Utility Umbrella
if (this.field.isWeather('sunnyday')) {
pokemon.addVolatile('protosynthesis');
} else if (!pokemon.volatiles['protosynthesis'] && pokemon.hasItem('boosterenergy')) {
pokemon.useItem();
} 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');
Expand Down
3 changes: 0 additions & 3 deletions sim/pokemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1492,9 +1492,6 @@ export class Pokemon {

this.volatileStaleness = undefined;

delete this.abilityState.started;
delete this.itemState.started;

this.setSpecies(this.baseSpecies);
}

Expand Down
15 changes: 15 additions & 0 deletions test/sim/items/boosterenergy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,19 @@ describe('Booster Energy', function () {
assert.equal(bundle.volatiles['quarkdrive'].bestStat, 'spa',
`Iron Bundle's Speed should have been lowered before Booster Energy activated, boosting its SpA instead.`);
});

it(`should activate right after weather changes`, function () {
battle = common.createBattle({gameType: 'doubles'}, [[
{species: 'Ninetales-Alola', ability: 'snowwarning', moves: ['sleeptalk']},
{species: 'Roaring Moon', item: 'boosterenergy', ability: 'protosynthesis', moves: ['sleeptalk']},
], [
{species: 'Incineroar', ability: 'intimidate', moves: ['sleeptalk']},
{species: 'Torkoal', ability: 'drought', moves: ['sleeptalk']},
]]);

const roaringMoon = battle.p1.active[1];
assert(roaringMoon.volatiles['protosynthesis'].fromBooster);
assert.equal(roaringMoon.volatiles['protosynthesis'].bestStat, 'atk');
assert.equal(battle.field.weather, 'sunnyday');
});
});
Loading