mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-05-18 03:01:00 -05:00
For side conditions, `onStart`/`onRestart`/`onResidual`/`onEnd` have been renamed `onSideStart`/`onSideRestart`/`onSideResidual`/`onSideEnd`, with the `onResidualOrder` properties renamed `onSideResidualOrder`. For field conditions, `onStart`/`onRestart`/`onResidual`/`onEnd` have been renamed `onFieldStart`/`onFieldRestart`/`onFieldResidual`/`onFieldEnd`, with the `onResidualOrder` properties renamed `onFieldResidualOrder`. (The `onField` and `onSide` part helps make it clear to the type system that the first argument is a Field or Side, not a Pokemon.) Side and field conditions can now use `onResidual` to tick separately on each pokemon in Speed order. `onResidualOrder` (the per-pokemon tick) can be timed separate from `onSideResidualOrder` (the per-condition tick), allowing conditions to end at a different priority than they tick per-pokemon. Relatedly, `onTeamPreview` and `onStart` in formats now need to be `onFieldTeamPreview` and `onFieldStart`. Unrelatedly, `effectData` has been renamed `effectState`, and the corresponding state containers (`pokemon.statusData`, `pokemon.speciesData`, `pokemon.itemData`, `pokemon.abilityData`, `field.weatherData`, `field.terrainData`) have been similarly renamed. I renamed the types a while ago, but I was holding off renaming the fields because it would be a breaking change. But this is a breaking change anyway, so we might as well do it now. Note: `onResidual` will tick even on `onSideEnd` turns, although `onSideResidual` won't. When refactoring weather, remember to check `this.state.duration` so you don't deal weather damage on the ending turn. Intended as a better fix for #8216
88 lines
3.9 KiB
JavaScript
88 lines
3.9 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('./../../assert');
|
|
const common = require('./../../common');
|
|
|
|
let battle;
|
|
|
|
describe('Disguise', function () {
|
|
afterEach(() => battle.destroy());
|
|
|
|
it('should block damage from one move', function () {
|
|
battle = common.gen(7).createBattle();
|
|
battle.setPlayer('p1', {team: [{species: 'Mimikyu', ability: 'disguise', moves: ['splash']}]});
|
|
battle.setPlayer('p2', {team: [{species: 'Mewtwo', ability: 'pressure', moves: ['psystrike']}]});
|
|
assert.false.hurts(battle.p1.active[0], () => battle.makeChoices());
|
|
assert.hurts(battle.p1.active[0], () => battle.makeChoices());
|
|
});
|
|
|
|
it('should only block damage from the first hit of a move', function () {
|
|
battle = common.gen(7).createBattle();
|
|
battle.setPlayer('p1', {team: [{species: 'Mimikyu', ability: 'disguise', moves: ['splash']}]});
|
|
battle.setPlayer('p2', {team: [{species: 'Beedrill', ability: 'swarm', moves: ['twineedle']}]});
|
|
assert.hurts(battle.p1.active[0], () => battle.makeChoices());
|
|
});
|
|
|
|
it('should block a hit from confusion', function () {
|
|
battle = common.gen(7).createBattle();
|
|
battle.setPlayer('p1', {team: [{species: 'Mimikyu', ability: 'disguise', moves: ['splash']}]});
|
|
battle.setPlayer('p2', {team: [{species: 'Sableye', ability: 'prankster', moves: ['confuseray']}]});
|
|
assert.false.hurts(battle.p1.active[0], () => battle.makeChoices());
|
|
assert(battle.p1.active[0].abilityState.busted);
|
|
});
|
|
|
|
it('should not block damage from weather effects', function () {
|
|
battle = common.createBattle();
|
|
battle.setPlayer('p1', {team: [{species: 'Mimikyu', ability: 'disguise', moves: ['splash']}]});
|
|
battle.setPlayer('p2', {team: [{species: 'Tyranitar', ability: 'sandstream', moves: ['rest']}]});
|
|
assert.hurts(battle.p1.active[0], () => battle.makeChoices());
|
|
});
|
|
|
|
it('should not block damage from entry hazards', function () {
|
|
battle = common.createBattle();
|
|
battle.setPlayer('p1', {team: [
|
|
{species: 'Zangoose', ability: 'toxicboost', item: 'laggingtail', moves: ['return']},
|
|
{species: 'Mimikyu', ability: 'disguise', moves: ['splash']},
|
|
]});
|
|
battle.setPlayer('p2', {team: [{species: 'forretress', ability: 'sturdy', item: 'redcard', moves: ['spikes']}]});
|
|
battle.makeChoices();
|
|
assert.false.fullHP(battle.p1.active[0]);
|
|
});
|
|
|
|
it('should not block status moves or damage from status', function () {
|
|
battle = common.createBattle();
|
|
battle.setPlayer('p1', {team: [{species: 'Mimikyu', ability: 'disguise', moves: ['splash']}]});
|
|
battle.setPlayer('p2', {team: [{species: 'Ariados', ability: 'swarm', moves: ['toxicthread']}]});
|
|
const pokemon = battle.p1.active[0];
|
|
assert.sets(() => pokemon.status, 'psn', () => battle.makeChoices());
|
|
assert.statStage(pokemon, 'spe', -1);
|
|
assert.false.fullHP(pokemon);
|
|
});
|
|
|
|
it('should not block secondary effects from damaging moves', function () {
|
|
battle = common.gen(7).createBattle();
|
|
battle.setPlayer('p1', {team: [{species: 'Mimikyu', ability: 'disguise', moves: ['splash']}]});
|
|
battle.setPlayer('p2', {team: [{species: 'Pikachu', ability: 'lightningrod', moves: ['nuzzle']}]});
|
|
const pokemon = battle.p1.active[0];
|
|
assert.sets(() => pokemon.status, 'par', () => battle.makeChoices());
|
|
assert.fullHP(pokemon);
|
|
});
|
|
|
|
it('should cause Counter to deal 1 damage if it blocks a move', function () {
|
|
battle = common.createBattle();
|
|
battle.setPlayer('p1', {team: [{species: 'Mimikyu', ability: 'disguise', moves: ['counter']}]});
|
|
battle.setPlayer('p2', {team: [{species: 'Weavile', ability: 'pressure', moves: ['feintattack']}]});
|
|
assert.hurtsBy(battle.p2.active[0], 1, () => battle.makeChoices());
|
|
});
|
|
|
|
it('should not trigger critical hits while active', function () {
|
|
battle = common.createBattle([[
|
|
{species: 'Mimikyu', ability: 'disguise', moves: ['sleeptalk']},
|
|
], [
|
|
{species: 'Cryogonal', ability: 'noguard', moves: ['frostbreath']},
|
|
]]);
|
|
battle.makeChoices();
|
|
assert(battle.log.every(line => !line.startsWith('|-crit')));
|
|
});
|
|
});
|