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 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
32 changes: 31 additions & 1 deletion data/abilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3422,16 +3422,31 @@ export const Abilities: import('../sim/dex-abilities').AbilityDataTable = {
protosynthesis: {
onStart(pokemon) {
this.singleEvent('WeatherChange', this.effect, this.effectState, pokemon);
this.effectState.started = true;
},
onWeatherChange(pokemon) {
// 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.transformed && !pokemon.volatiles['protosynthesis'] && pokemon.hasItem('boosterenergy') &&
this.effectState.started) {
pokemon.useItem();
} else if (!pokemon.volatiles['protosynthesis']?.fromBooster) {
pokemon.removeVolatile('protosynthesis');
}
},
onUpdate(pokemon) {
// don't trigger before hazards
if (pokemon.transformed) return;
if (this.queue.peek(true)?.choice === 'runSwitch') return;

if (!pokemon.volatiles['protosynthesis'] && !this.field.isWeather('sunnyday') && pokemon.hasItem('boosterenergy') &&
pokemon.itemState.started) {
pokemon.useItem();
}
},
onEnd(pokemon) {
delete this.effectState.started;
delete pokemon.volatiles['protosynthesis'];
this.add('-end', pokemon, 'Protosynthesis', '[silent]');
},
Expand Down Expand Up @@ -3558,15 +3573,30 @@ export const Abilities: import('../sim/dex-abilities').AbilityDataTable = {
quarkdrive: {
onStart(pokemon) {
this.singleEvent('TerrainChange', this.effect, this.effectState, pokemon);
this.effectState.started = true;
},
onTerrainChange(pokemon) {
if (this.field.isTerrain('electricterrain')) {
pokemon.addVolatile('quarkdrive');
} else if (!pokemon.transformed && !pokemon.volatiles['quarkdrive'] && pokemon.hasItem('boosterenergy') &&
this.effectState.started) {
pokemon.useItem();
} else if (!pokemon.volatiles['quarkdrive']?.fromBooster) {
pokemon.removeVolatile('quarkdrive');
}
},
onUpdate(pokemon) {
// don't trigger before hazards
if (pokemon.transformed) return;
if (this.queue.peek(true)?.choice === 'runSwitch') return;

if (!pokemon.volatiles['quarkdrive'] && !this.field.isTerrain('electricterrain') && pokemon.hasItem('boosterenergy') &&
pokemon.itemState.started) {
pokemon.useItem();
}
},
onEnd(pokemon) {
delete this.effectState.started;
delete pokemon.volatiles['quarkdrive'];
this.add('-end', pokemon, 'Quark Drive', '[silent]');
},
Expand Down
12 changes: 2 additions & 10 deletions data/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,16 +617,8 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
onStart() {
this.effectState.started = true;
},
onUpdate(pokemon) {
if (!this.effectState.started || pokemon.transformed) return;
if (this.queue.peek(true)?.choice === 'runSwitch') 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
1 change: 1 addition & 0 deletions sim/dex-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export class Item extends BasicEffect implements Readonly<BasicEffect> {

declare readonly onEat?: ((this: Battle, pokemon: Pokemon) => void) | false;
declare readonly onPrimal?: (this: Battle, pokemon: Pokemon) => void;
declare readonly onUse?: ((this: Battle, pokemon: Pokemon) => void) | false;
declare readonly onStart?: (this: Battle, target: Pokemon) => void;
declare readonly onEnd?: (this: Battle, target: Pokemon) => void;

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