Files
pokemon-showdown/test/sim/items/protectivepads.js
Guangcong Luo 78439b4a02 Update to ESLint 9 (#10926)
ESLint has a whole new config format, so I figure it's a good time to
make the config system saner.

- First, we no longer have separate eslint-no-types configs. Lint
  performance shouldn't be enough of a problem to justify the
  relevant maintenance complexity.

- Second, our base config should work out-of-the-box now. `npx eslint`
  will work as expected, without any CLI flags. You should still use
  `npm run lint` which adds the `--cached` flag for performance.

- Third, whatever updates I did fixed style linting, which apparently
  has been bugged for quite some time, considering all the obvious
  mixed-tabs-and-spaces issues I found in the upgrade.

Also here are some changes to our style rules. In particular:

- Curly brackets (for objects etc) now have spaces inside them. Sorry
  for the huge change. ESLint doesn't support our old style, and most
  projects use Prettier style, so we might as well match them in this way.
  See https://github.com/eslint-stylistic/eslint-stylistic/issues/415

- String + number concatenation is no longer allowed. We now
  consistently use template strings for this.
2025-02-25 20:03:46 -08:00

131 lines
5.5 KiB
JavaScript

'use strict';
const assert = require('./../../assert');
const common = require('./../../common');
let battle;
describe('Protective Pads', () => {
afterEach(() => {
battle.destroy();
});
it(`should prevent ability-changing abilities triggered by contact from acting`, () => {
battle = common.createBattle([[
{ species: 'wynaut', ability: 'sturdy', item: 'protectivepads', moves: ['bulletpunch'] },
], [
{ species: 'cofagrigus', ability: 'mummy', moves: ['sleeptalk'] },
]]);
const wynaut = battle.p1.active[0];
battle.makeChoices();
assert.equal(wynaut.ability, 'sturdy');
const mummyActivationMessages = battle.log.filter(logStr => logStr.startsWith('|-activate|') && logStr.includes('Mummy'));
assert.equal(mummyActivationMessages.length, 1, `Mummy should activate only once`);
assert(mummyActivationMessages[0].includes('Cofagrigus'), `Source of Mummy activation should be included`);
assert.false(mummyActivationMessages[0].includes('Sturdy'), `Attacker's ability should not be revealed`);
});
it(`should prevent damaging abilities triggered by contact from acting`, () => {
battle = common.createBattle([[
{ species: 'wynaut', item: 'protectivepads', moves: ['bulletpunch'] },
], [
{ species: 'ferrothorn', ability: 'ironbarbs', moves: ['sleeptalk'] },
]]);
battle.makeChoices();
assert.fullHP(battle.p1.active[0], `Attacker should not be damaged`);
assert(battle.log.some(line => line.includes('Iron Barbs')));
assert(battle.log.some(line => line.includes('Protective Pads')));
});
it(`should prevent stat stage-changing abilities triggered by contact from acting`, () => {
battle = common.createBattle([[
{ species: 'wynaut', item: 'protectivepads', moves: ['bulletpunch'] },
], [
{ species: 'goodra', ability: 'gooey', moves: ['sleeptalk'] },
]]);
battle.makeChoices();
assert.statStage(battle.p1.active[0], 'spe', 0, `Speed should not be lowered`);
assert(battle.log.some(line => line.includes('Gooey')));
assert(battle.log.some(line => line.includes('Protective Pads')));
});
it(`should not stop Pickpocket`, () => {
battle = common.createBattle([[
{ species: 'wynaut', item: 'protectivepads', moves: ['bulletpunch'] },
], [
{ species: 'weavile', ability: 'pickpocket', moves: ['sleeptalk'] },
]]);
battle.makeChoices();
assert.false.holdsItem(battle.p1.active[0], `Attacker should lose their item`);
assert.equal(battle.p2.active[0].item, 'protectivepads', `Target should receive stolen Protective Pads`);
});
it(`should prevent item effects triggered by contact from acting`, () => {
battle = common.createBattle([[
{ species: 'wynaut', item: 'protectivepads', moves: ['bulletpunch'] },
], [
{ species: 'miltank', item: 'rockyhelmet', moves: ['sleeptalk'] },
]]);
battle.makeChoices();
assert.fullHP(battle.p1.active[0], `Attacker should not be hurt`);
assert(battle.log.every(line => !line.includes('Rocky Helmet')));
assert(battle.log.every(line => !line.includes('Protective Pads')));
});
it(`should not activate on the opponent's moves`, () => {
battle = common.createBattle([[
{ species: 'wynaut', item: 'protectivepads', moves: ['sleeptalk'] },
], [
{ species: 'happiny', moves: ['lunge'] },
]]);
battle.makeChoices();
assert.statStage(battle.p1.active[0], 'atk', -1, `Attack should be lowered`);
});
it(`should not start Perish Body on either Pokemon`, () => {
battle = common.createBattle([[
{ species: 'wynaut', item: 'protectivepads', moves: ['bulletpunch'] },
], [
{ species: 'cursola', ability: 'perishbody', moves: ['sleeptalk'] },
]]);
battle.makeChoices();
assert.false(battle.p1.active[0].volatiles['perishsong'], 'Perish Body should not have activated on Wynaut due to Protective Pads.');
assert.false(battle.p2.active[0].volatiles['perishsong'], 'Perish Body should not have activated on Cursola due to Protective Pads.');
assert(battle.log.every(line => !line.includes('Perish Body')));
assert(battle.log.every(line => !line.includes('Protective Pads')));
});
it(`should block against Protecting effects with a contact side effect`, () => {
battle = common.createBattle([[
{ species: 'wynaut', item: 'protectivepads', moves: ['sleeptalk', 'tackle'] },
], [
{ species: 'aggron', moves: ['sleeptalk', 'banefulbunker', 'obstruct', 'spikyshield'] },
]]);
battle.makeChoices('move tackle', 'move banefulbunker');
battle.makeChoices();
battle.makeChoices('move tackle', 'move obstruct');
battle.makeChoices();
battle.makeChoices('move tackle', 'move spikyshield');
battle.makeChoices();
const wynaut = battle.p1.active[0];
assert.equal(wynaut.status, '', `Wynaut should not have been poisoned by Baneful Bunker`);
assert.statStage(wynaut, 'def', 0, `Wynaut's Defense should not have been lowered by Obstruct`);
assert.fullHP(wynaut, `Wynaut should not have lost HP from Spiky Shield`);
assert(battle.log.every(line => !line.includes('Protective Pads')));
});
it(`should not protect against Gulp Missile when using a contact move`, () => {
battle = common.createBattle([[
{ species: 'wynaut', item: 'protectivepads', moves: ['bulletpunch'] },
], [
{ species: 'cramorantgorging', ability: 'gulpmissile', item: 'rockyhelmet', moves: ['sleeptalk'] },
]]);
battle.makeChoices();
const wynaut = battle.p1.active[0];
assert.equal(wynaut.hp, wynaut.maxhp - Math.floor(wynaut.maxhp / 4), `Wynaut should be damaged by Gulp Missile, but not Rocky Helmet`);
assert.equal(wynaut.status, 'par');
assert(battle.log.every(line => !line.includes('Protective Pads')));
});
});