Correct Room Service event timing (#8959)

This commit is contained in:
Leonard Craft III
2022-10-30 17:42:03 -05:00
committed by GitHub
parent 2d8a955e24
commit ff4e51f728
4 changed files with 44 additions and 1 deletions

View File

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

View File

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

View File

@@ -208,6 +208,7 @@ export class Field {
delete this.pseudoWeather[status.id];
return false;
}
this.battle.runEvent('PseudoWeatherStart', source, source, status);
return true;
}

View File

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