Files
pokemon-showdown/test/sim/abilities/magicbounce.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

88 lines
3.8 KiB
JavaScript

'use strict';
const assert = require('./../../assert');
const common = require('./../../common');
let battle;
describe('Magic Bounce', () => {
afterEach(() => {
battle.destroy();
});
it('should bounce Growl', () => {
// Sanity check: if this test fails, the remaining tests for Magic Bounce may not make sense.
// Tests for specific moves belong to the respective moves' test suites.
battle = common.createBattle();
battle.setPlayer('p1', { team: [{ species: "Bulbasaur", ability: 'overgrow', moves: ['growl'] }] });
battle.setPlayer('p2', { team: [{ species: "Espeon", ability: 'magicbounce', moves: ['futuresight'] }] });
battle.makeChoices('move growl', 'move futuresight');
assert.statStage(battle.p1.active[0], 'atk', -1);
assert.statStage(battle.p2.active[0], 'atk', 0);
});
it('should bounce once when target and source share the ability', () => {
battle = common.createBattle();
battle.setPlayer('p1', { team: [{ species: "Xatu", ability: 'magicbounce', moves: ['roost'] }] });
battle.setPlayer('p2', { team: [{ species: "Espeon", ability: 'magicbounce', moves: ['growl'] }] });
assert.doesNotThrow(() => battle.makeChoices('move roost', 'move growl'));
assert.statStage(battle.p1.active[0], 'atk', 0);
assert.statStage(battle.p2.active[0], 'atk', -1);
});
it('should not cause a choice-lock', () => {
battle = common.createBattle();
battle.setPlayer('p1', { team: [
{ species: "Spoink", ability: 'thickfat', moves: ['bounce'] },
{ species: "Xatu", item: 'choicescarf', ability: 'magicbounce', moves: ['roost', 'growl'] },
] });
battle.setPlayer('p2', { team: [{ species: "Espeon", ability: 'magicbounce', moves: ['growl', 'recover'] }] });
battle.makeChoices('switch 2', 'move growl');
battle.makeChoices('move roost', 'move recover');
assert.notEqual(battle.p1.active[0].lastMove.id, 'growl');
});
it('should be suppressed by Mold Breaker', () => {
battle = common.createBattle();
battle.setPlayer('p1', { team: [{ species: "Bulbasaur", ability: 'moldbreaker', moves: ['growl'] }] });
battle.setPlayer('p2', { team: [{ species: "Espeon", ability: 'magicbounce', moves: ['futuresight'] }] });
battle.makeChoices('move growl', 'move futuresight');
assert.statStage(battle.p1.active[0], 'atk', 0);
assert.statStage(battle.p2.active[0], 'atk', -1);
});
it('should not bounce moves while semi-invulnerable', () => {
battle = common.createBattle({ gameType: 'doubles' });
battle.setPlayer('p1', { team: [
{ species: "Bulbasaur", ability: 'overgrow', moves: ['growl'] },
{ species: "Geodude", ability: 'rockhead', moves: ['stealthrock'] },
] });
battle.setPlayer('p2', { team: [
{ species: "Xatu", ability: 'magicbounce', moves: ['fly'] },
{ species: "Charmander", ability: 'blaze', moves: ['sleeptalk'] },
] });
battle.makeChoices('auto', 'auto');
assert.statStage(battle.p1.active[0], 'atk', 0);
assert.statStage(battle.p2.active[0], 'atk', 0);
assert.false(battle.p1.sideConditions['stealthrock']);
assert(battle.p2.sideConditions['stealthrock']);
});
it(`[Gen 5] should bounce moves that target the foe's side while semi-invulnerable`, () => {
battle = common.gen(5).createBattle({ gameType: 'doubles' });
battle.setPlayer('p1', { team: [
{ species: "Bulbasaur", ability: 'overgrow', moves: ['growl'] },
{ species: "Geodude", ability: 'rockhead', moves: ['stealthrock'] },
] });
battle.setPlayer('p2', { team: [
{ species: "Xatu", ability: 'magicbounce', moves: ['fly'] },
{ species: "Charmander", ability: 'blaze', moves: ['sleeptalk'] },
] });
battle.makeChoices('auto', 'auto');
assert.statStage(battle.p1.active[0], 'atk', 0);
assert.statStage(battle.p2.active[0], 'atk', 0);
assert(battle.p1.sideConditions['stealthrock']);
assert.false(battle.p2.sideConditions['stealthrock']);
});
});