Files
pokemon-showdown/test/sim/moves/disable.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

123 lines
3.9 KiB
JavaScript

'use strict';
const assert = require('./../../assert');
const common = require('./../../common');
let battle;
describe('Disable', () => {
afterEach(() => {
battle.destroy();
});
it(`should prevent the use of the target's last move`, () => {
battle = common.createBattle([[
{ species: "Wynaut", moves: ['disable'] },
], [
{ species: "Spearow", moves: ['growl'] },
]]);
battle.makeChoices();
assert.cantMove(() => battle.makeChoices('auto', 'move growl'), "Spearow", 'growl');
});
it(`should interupt consecutively executed moves like Outrage`, () => {
battle = common.createBattle([[
{ species: "Wynaut", moves: ['disable'] },
], [
{ species: "Spearow", moves: ['outrage', 'sleeptalk'] },
]]);
battle.makeChoices();
assert.cantMove(() => battle.makeChoices('auto', 'move sleeptalk'), "Spearow", 'sleeptalk');
battle.makeChoices();
assert.cantMove(() => battle.makeChoices('auto', 'move outrage'));
});
it(`should not work successfully against Struggle`, () => {
battle = common.createBattle([[
{ species: "Wynaut", moves: ['disable'] },
], [
{ species: "Spearow", item: 'assaultvest', moves: ['growl'] },
]]);
battle.makeChoices();
assert(battle.log.indexOf('|-fail|p1a: Wynaut') > 0, `Disable should have failed vs Struggle`);
});
describe(`[Gen 1] Disable`, () => {
it(`should fail if the opponent already has a move disabled`, () => {
battle = common.createBattle({ forceRandomChance: true }, [[
{ species: 'Mew', moves: ['disable'] },
], [
{ species: 'Muk', moves: ['splash', 'tackle'] },
]]);
battle.makeChoices('auto', 'move tackle');
battle.makeChoices('auto', 'move splash');
battle.makeChoices('auto', 'move splash');
assert(battle.log.includes('|-fail|p1a: Mew'), `Disable should fail if a move is already disabled`);
});
it(`should work on the first turn so long as the opponent has move with PP`, () => {
battle = common.gen(1).createBattle({ forceRandomChance: true }, [[
{ species: 'Mew', moves: ['disable'] },
], [
{ species: 'Muk', moves: ['roar'] },
]]);
battle.makeChoices();
assert('disable' in battle.p2.active[0].volatiles);
});
it(`should fail if opponent has no moves with PP`, () => {
battle = common.gen(1).createBattle({ forceRandomChance: true }, [[
{ species: 'Mew', moves: ['disable'] },
], [
{ species: 'Muk', moves: ['hyperbeam'] },
]]);
battle.p2.active[0].deductPP('hyperbeam', 8);
battle.makeChoices();
assert(battle.log.includes('|-fail|p2a: Muk'), 'Muk has no moves with positive PP');
});
it(`should not select moves with 0 PP`, () => {
battle = common.gen(1).createBattle({ forceRandomChance: true }, [[
{ species: 'Mew', moves: ['disable'] },
], [
{ species: 'Muk', moves: ['hyperbeam', 'fireblast', 'blizzard', 'tackle'] },
]]);
const muk = battle.p2.active[0];
muk.deductPP('hyperbeam', 8);
muk.deductPP('fireblast', 8);
muk.deductPP('blizzard', 8);
battle.makeChoices('auto', 'move tackle');
assert('disable' in muk.volatiles);
assert.equal(muk.volatiles.disable.move, 'tackle');
});
it(`Disable should build Rage, even if it misses/fails`, () => {
// Disable hits
battle = common.gen(1).createBattle([[
{ species: 'Drowzee', moves: ['disable'] },
], [
{ species: 'Abra', moves: ['rage'] },
]]);
// Modding accuracy so Disable always hits
battle.onEvent('Accuracy', battle.format, true);
battle.makeChoices();
assert(battle.log.some(line => line.startsWith('|-boost|')));
battle = common.gen(1).createBattle([[
{ species: 'Drowzee', moves: ['disable'] },
], [
{ species: 'Abra', moves: ['rage'] },
]]);
// Modding accuracy so Disable always misses
battle.onEvent('Accuracy', battle.format, (accuracy, target, pokemon, move) => {
return move.id === 'rage';
});
battle.makeChoices();
assert(battle.log.some(line => line.startsWith('|-boost|')));
});
});
});