pokemon-showdown/test/sim/misc/weight.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

154 lines
4.6 KiB
JavaScript

'use strict';
const assert = require('./../../assert');
const common = require('./../../common');
let battle;
describe('Heavy Metal', () => {
afterEach(() => {
battle.destroy();
});
it('should double the weight of a Pokemon', () => {
battle = common.createBattle([
[{ species: "Simisear", ability: 'heavymetal', moves: ['nastyplot'] }],
[{ species: "Simisage", ability: 'gluttony', moves: ['grassknot'] }],
]);
let basePower = 0;
battle.onEvent('BasePower', battle.format, (bp, attacker, defender, move) => {
if (move.id === 'grassknot') {
basePower = bp;
}
});
battle.makeChoices('move nastyplot', 'move grassknot');
assert.equal(basePower, 80);
});
it('should be negated by Mold Breaker', () => {
battle = common.createBattle([
[{ species: "Simisear", ability: 'heavymetal', moves: ['nastyplot'] }],
[{ species: "Simisage", ability: 'moldbreaker', moves: ['grassknot'] }],
]);
let basePower = 0;
battle.onEvent('BasePower', battle.format, (bp, attacker, defender, move) => {
if (move.id === 'grassknot') {
basePower = bp;
}
});
battle.makeChoices('move nastyplot', 'move grassknot');
assert.equal(basePower, 60);
});
});
describe('Light Metal', () => {
afterEach(() => {
battle.destroy();
});
it('should halve the weight of a Pokemon', () => {
battle = common.createBattle([
[{ species: "Registeel", ability: 'lightmetal', moves: ['curse'] }],
[{ species: "Simisage", ability: 'gluttony', moves: ['grassknot'] }],
]);
let basePower = 0;
battle.onEvent('BasePower', battle.format, (bp, attacker, defender, move) => {
if (move.id === 'grassknot') {
basePower = bp;
}
});
battle.makeChoices('move curse', 'move grassknot');
assert.equal(basePower, 100);
});
it('should be negated by Mold Breaker', () => {
battle = common.createBattle([
[{ species: "Registeel", ability: 'lightmetal', moves: ['splash'] }],
[{ species: "Simisage", ability: 'moldbreaker', moves: ['grassknot'] }],
]);
let basePower = 0;
battle.onEvent('BasePower', battle.format, (bp, attacker, defender, move) => {
if (move.id === 'grassknot') {
basePower = bp;
}
});
battle.makeChoices('move splash', 'move grassknot');
assert.equal(basePower, 120);
});
});
describe('Float Stone', () => {
afterEach(() => {
battle.destroy();
});
it('should halve the weight of a Pokemon', () => {
battle = common.createBattle([
[{ species: "Registeel", ability: 'clearbody', item: 'floatstone', moves: ['curse'] }],
[{ species: "Simisage", ability: 'gluttony', moves: ['grassknot'] }],
]);
let basePower = 0;
battle.onEvent('BasePower', battle.format, (bp, attacker, defender, move) => {
if (move.id === 'grassknot') {
basePower = bp;
}
});
battle.makeChoices('move curse', 'move grassknot');
assert.equal(basePower, 100);
});
});
describe('Autotomize', () => {
afterEach(() => {
battle.destroy();
});
it('should reduce the weight of a Pokemon by 100 kg with each use', () => {
battle = common.createBattle([
[{ species: "Registeel", ability: 'clearbody', moves: ['autotomize'] }],
[{ species: "Simisage", ability: 'gluttony', item: 'laggingtail', moves: ['grassknot'] }],
]);
let basePower = 0;
battle.onEvent('BasePower', battle.format, (bp, attacker, defender, move) => {
if (move.id === 'grassknot') {
basePower = bp;
}
});
battle.makeChoices('move autotomize', 'move grassknot');
assert.equal(basePower, 100);
battle.makeChoices('move autotomize', 'move grassknot');
assert.equal(basePower, 20);
});
it('should factor into weight before Heavy Metal does', () => {
battle = common.createBattle([
[{ species: "Lairon", ability: 'heavymetal', moves: ['autotomize'] }],
[{ species: "Simisage", ability: 'gluttony', item: 'laggingtail', moves: ['grassknot'] }],
]);
let basePower = 0;
battle.onEvent('BasePower', battle.format, (bp, attacker, defender, move) => {
if (move.id === 'grassknot') {
basePower = bp;
}
});
battle.makeChoices('move autotomize', 'move grassknot');
assert.equal(basePower, 60);
});
it('should reset after a forme change', () => {
battle = common.createBattle([
[{ species: "Aegislash", ability: 'stancechange', moves: ['autotomize', 'shadowsneak'] }],
[{ species: "Simisage", ability: 'gluttony', item: 'laggingtail', moves: ['grassknot'] }],
]);
let basePower = 0;
battle.onEvent('BasePower', battle.format, (bp, attacker, defender, move) => {
if (move.id === 'grassknot') {
basePower = bp;
}
});
battle.makeChoices('move autotomize', 'move grassknot');
battle.makeChoices('move shadowsneak', 'move grassknot');
assert.equal(basePower, 80);
});
});