diff --git a/data/items.ts b/data/items.ts index 9cbb084daf..110ae125c3 100644 --- a/data/items.ts +++ b/data/items.ts @@ -4576,7 +4576,13 @@ export const Items: {[itemid: string]: ItemData} = { fling: { basePower: 100, }, - onUpdate(pokemon) { + onStart(pokemon) { + if (!pokemon.ignoringItem() && this.field.getPseudoWeather('trickroom')) { + pokemon.useItem(); + } + }, + onAnyPseudoWeatherStart() { + const pokemon = this.effectState.target; if (this.field.getPseudoWeather('trickroom')) { pokemon.useItem(); } diff --git a/sim/dex-conditions.ts b/sim/dex-conditions.ts index 5706e86225..5f9b928bf8 100644 --- a/sim/dex-conditions.ts +++ b/sim/dex-conditions.ts @@ -375,6 +375,7 @@ export interface EventMethods { onAnyNegateImmunity?: ((this: Battle, pokemon: Pokemon, type: string) => boolean | void) | boolean; onAnyOverrideAction?: (this: Battle, pokemon: Pokemon, target: Pokemon, move: ActiveMove) => string | void; onAnyPrepareHit?: CommonHandlers['ResultSourceMove']; + onAnyPseudoWeatherStart?: (this: Battle, target: Pokemon, source: Pokemon, pseudoWeather: Condition) => void; onAnyRedirectTarget?: ( this: Battle, target: Pokemon, source: Pokemon, source2: Effect, move: ActiveMove ) => Pokemon | void; diff --git a/sim/field.ts b/sim/field.ts index 07925d8585..2057a431fa 100644 --- a/sim/field.ts +++ b/sim/field.ts @@ -208,6 +208,7 @@ export class Field { delete this.pseudoWeather[status.id]; return false; } + this.battle.runEvent('PseudoWeatherStart', source, source, status); return true; } diff --git a/test/sim/items/roomservice.js b/test/sim/items/roomservice.js new file mode 100644 index 0000000000..f46f4eb0a0 --- /dev/null +++ b/test/sim/items/roomservice.js @@ -0,0 +1,35 @@ +'use strict'; + +const assert = require('./../../assert'); +const common = require('./../../common'); + +let battle; + +describe('Room Service', function () { + afterEach(function () { + battle.destroy(); + }); + + it(`should activate when Trick Room is set`, function () { + battle = common.createBattle([[ + {species: 'slowpoke', item: 'roomservice', moves: ['sleeptalk']}, + ], [ + {species: 'whimsicott', item: 'roomservice', moves: ['trickroom']}, + ]]); + battle.makeChoices(); + assert.statStage(battle.p1.active[0], 'spe', -1); + assert.statStage(battle.p2.active[0], 'spe', -1); + }); + + it(`should activate after entrance Abilities`, function () { + battle = common.createBattle([[ + {species: 'slowpoke', moves: ['teleport']}, + {species: 'ditto', ability: 'imposter', item: 'roomservice', moves: ['transform']}, + ], [ + {species: 'whimsicott', ability: 'prankster', moves: ['trickroom']}, + ]]); + battle.makeChoices(); + battle.makeChoices(); + assert.statStage(battle.p1.active[0], 'spe', -1, `Ditto-Whimsicott should be at -1 Speed after transforming`); + }); +});