mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-08-22 00:54:31 -05:00
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.
95 lines
3.7 KiB
JavaScript
95 lines
3.7 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('./../../assert');
|
|
const common = require('./../../common');
|
|
|
|
let battle;
|
|
|
|
describe('Sturdy', () => {
|
|
afterEach(() => {
|
|
battle.destroy();
|
|
});
|
|
|
|
it('should give the user an immunity to OHKO moves', () => {
|
|
battle = common.createBattle();
|
|
battle.setPlayer('p1', { team: [{ species: 'Aron', level: 1, ability: 'sturdy', moves: ['sleeptalk'] }] });
|
|
battle.setPlayer('p2', { team: [{ species: 'Kyogre', ability: 'noguard', moves: ['sheercold'] }] });
|
|
assert.false.hurts(battle.p1.active[0], () => battle.makeChoices('move sleeptalk', 'move sheercold'));
|
|
});
|
|
|
|
it('should allow its user to survive an attack from full HP', () => {
|
|
battle = common.createBattle();
|
|
battle.setPlayer('p1', { team: [{ species: 'Paras', ability: 'sturdy', moves: ['sleeptalk'] }] });
|
|
battle.setPlayer('p2', { team: [{ species: 'Charizard', ability: 'drought', moves: ['fusionflare'] }] });
|
|
battle.makeChoices('move sleeptalk', 'move fusionflare');
|
|
assert.equal(battle.p1.active[0].hp, 1);
|
|
});
|
|
|
|
it('should allow its user to survive a confusion damage hit from full HP', () => {
|
|
battle = common.createBattle();
|
|
battle.setPlayer('p1', { team: [{ species: 'Shedinja', ability: 'sturdy', moves: ['absorb'] }] });
|
|
battle.setPlayer('p2', { team: [{ species: 'Klefki', ability: 'prankster', moves: ['confuseray'] }] });
|
|
battle.makeChoices('move absorb', 'move confuseray');
|
|
assert.equal(battle.p1.active[0].hp, 1);
|
|
});
|
|
|
|
it('should not trigger on recoil damage', () => {
|
|
battle = common.createBattle();
|
|
battle.setPlayer('p1', { team: [{ species: 'Shedinja', ability: 'sturdy', moves: ['doubleedge'] }] });
|
|
battle.setPlayer('p2', { team: [{ species: 'Klefki', ability: 'prankster', moves: ['reflect'] }] });
|
|
battle.makeChoices('move doubleedge', 'move reflect');
|
|
assert.fainted(battle.p1.active[0]);
|
|
});
|
|
|
|
it('should not trigger on residual damage', () => {
|
|
battle = common.createBattle();
|
|
battle.setPlayer('p1', { team: [{ species: 'Shedinja', ability: 'sturdy', moves: ['sleeptalk'] }] });
|
|
battle.setPlayer('p2', { team: [{ species: 'Crobat', ability: 'infiltrator', moves: ['toxic'] }] });
|
|
battle.makeChoices('move sleeptalk', 'move toxic');
|
|
assert.fainted(battle.p1.active[0]);
|
|
});
|
|
|
|
it('should be suppressed by Mold Breaker', () => {
|
|
battle = common.createBattle();
|
|
battle.setPlayer('p1', { team: [{ species: 'Paras', ability: 'sturdy', moves: ['sleeptalk'] }] });
|
|
battle.setPlayer('p2', { team: [{ species: 'Reshiram', ability: 'turboblaze', moves: ['fusionflare'] }] });
|
|
battle.makeChoices('move sleeptalk', 'move fusionflare');
|
|
assert.fainted(battle.p1.active[0]);
|
|
});
|
|
|
|
it(`should trigger before Focus Sash`, () => {
|
|
battle = common.createBattle([[
|
|
{ species: "Wynaut", moves: ['tackle'] },
|
|
], [
|
|
{ species: "Stufful", level: 1, ability: 'sturdy', item: 'focussash', moves: ['sleeptalk'] },
|
|
]]);
|
|
|
|
battle.makeChoices();
|
|
assert.holdsItem(battle.p2.active[0]);
|
|
});
|
|
|
|
it(`should not trigger when the user also uses Endure`, () => {
|
|
battle = common.createBattle([[
|
|
{ species: "Wynaut", moves: ['tackle'] },
|
|
], [
|
|
{ species: "Stufful", level: 1, ability: 'sturdy', moves: ['endure'] },
|
|
]]);
|
|
|
|
battle.makeChoices();
|
|
const sturdyIndex = battle.getDebugLog().indexOf('|-ability|p2a: Stufful|Sturdy');
|
|
assert.equal(sturdyIndex, -1, 'Sturdy should not activate.');
|
|
});
|
|
|
|
it(`should not trigger when the user is damaged to 1 HP from False Swipe`, () => {
|
|
battle = common.createBattle([[
|
|
{ species: "Wynaut", moves: ['falseswipe'] },
|
|
], [
|
|
{ species: "Stufful", level: 1, ability: 'sturdy', moves: ['sleeptalk'] },
|
|
]]);
|
|
|
|
battle.makeChoices();
|
|
const sturdyIndex = battle.getDebugLog().indexOf('|-ability|p2a: Stufful|Sturdy');
|
|
assert.equal(sturdyIndex, -1, 'Sturdy should not activate.');
|
|
});
|
|
});
|