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

111 lines
3.6 KiB
JavaScript

'use strict';
const assert = require('./../../assert');
const common = require('./../../common');
let battle;
describe('Unaware', () => {
afterEach(() => {
battle.destroy();
});
it(`should ignore attack stage changes when Pokemon with it are attacked`, () => {
battle = common.createBattle([[
{ species: 'Clefable', ability: 'unaware', moves: ['softboiled'] },
], [
{ species: 'Wynaut', moves: ['bellydrum', 'wickedblow'] },
]]);
battle.makeChoices('auto', 'move bellydrum');
battle.makeChoices('auto', 'move wickedblow');
const clef = battle.p1.active[0];
const damage = clef.maxhp - clef.hp;
assert.bounded(damage, [19, 22]);
});
it(`should not ignore attack stage changes when Pokemon with it attack`, () => {
battle = common.createBattle([[
{ species: 'Clefable', ability: 'unaware', moves: ['moonblast', 'nastyplot'] },
], [
{ species: 'Registeel', ability: 'shellarmor', moves: ['sleeptalk'] },
]]);
battle.makeChoices('move nastyplot', 'auto');
battle.makeChoices('move moonblast', 'auto');
const regi = battle.p2.active[0];
const damage = regi.maxhp - regi.hp;
assert.bounded(damage, [69, 81]);
});
it(`should ignore defense stage changes when Pokemon with it attack`, () => {
battle = common.createBattle([[
{ species: 'Clefable', ability: 'unaware', item: 'laggingtail', moves: ['moonblast'] },
], [
{ species: 'Registeel', ability: 'shellarmor', moves: ['amnesia'] },
]]);
battle.makeChoices();
const regi = battle.p2.active[0];
const damage = regi.maxhp - regi.hp;
assert.bounded(damage, [34, 41]);
});
it(`should not ignore defense stage changes when Pokemon with it are attacked`, () => {
battle = common.createBattle([[
{ species: 'Clefable', ability: 'unaware', moves: ['luckychant', 'irondefense'] },
], [
{ species: 'Registeel', moves: ['sleeptalk', 'payday'] },
]]);
battle.makeChoices();
battle.makeChoices('move irondefense', 'move payday');
const clef = battle.p1.active[0];
const damage = clef.maxhp - clef.hp;
assert.bounded(damage, [16, 19]);
});
it(`should be suppressed by Mold Breaker`, () => {
battle = common.createBattle([[
{ species: 'Clefable', ability: 'unaware', moves: ['softboiled'] },
], [
{ species: 'Wynaut', ability: 'moldbreaker', moves: ['bellydrum', 'wickedblow'] },
]]);
battle.makeChoices('auto', 'move bellydrum');
battle.makeChoices('auto', 'move wickedblow');
const clef = battle.p1.active[0];
const damage = clef.maxhp - clef.hp;
assert.bounded(damage, [73, 86]);
});
it(`should only apply to targets with Unaware in battles with multiple Pokemon`, () => {
battle = common.createBattle({ gameType: 'doubles' }, [[
{ species: 'manaphy', moves: ['tailglow', 'surf'] },
{ species: 'slowbro', ability: 'unaware', moves: ['sleeptalk'] },
], [
{ species: 'clobbopus', ability: 'sturdy', moves: ['sleeptalk'] },
{ species: 'clobbopus', ability: 'sturdy', moves: ['sleeptalk'] },
]]);
battle.makeChoices('move tailglow, auto', 'auto');
battle.makeChoices('move surf, auto', 'auto');
assert.equal(battle.p2.active[0].hp, 1);
assert.equal(battle.p2.active[1].hp, 1);
});
it(`should ignore attack stage changes when Pokemon with it are attacked with Foul Play`, () => {
battle = common.createBattle([[
{ species: 'Clefable', ability: 'unaware', moves: ['bellydrum'] },
], [
{ species: 'Wynaut', ability: 'superluck', moves: ['focusenergy', 'foulplay'] },
]]);
battle.makeChoices();
battle.makeChoices('auto', 'move foulplay');
const clef = battle.p1.active[0];
const damage = clef.maxhp - Math.floor(clef.maxhp / 2) - clef.hp;
assert.bounded(damage, [50, 59]);
});
});