pokemon-showdown/test/sim/abilities/comatose.js
Guangcong Luo 13189fdb02
Update Dex API (#8181)
This is the change that renames:

- `Dex.getMove` -> `Dex.moves.get`
- `Dex.getAbility` -> `Dex.abilities.get`
- `Dex.getItem` -> `Dex.items.get`
- `Dex.getSpecies` -> `Dex.species.get`
- `Dex.getEffect` -> `Dex.conditions.get`
- `Dex.getNature` -> `Dex.natures.get`
- `Dex.getType` -> `Dex.types.get`
- `Dex.getFormat` -> `Dex.formats.get`

In addition, some other APIs have been updated:

- `getByID` methods have also been added to every other table.
- `Dex.moves.all()` now gets an array of all moves
  - Plus equivalent methods for `abilities`, `items`, `species`, `formats`, `natures`, `types`
  - Note: there's no `Dex.conditions.all()`
- new API: `Dex.stats` for naming/iterating stats
- `Dex.getEffectByID` -> `Dex.conditions.getByID`
- `Dex.getType` -> `Dex.types.get`
- `Dex.data.Formats` -> `Dex.data.Rulesets`
- `Dex.formats` -> now an array `Dex.formats.all()`
- `Dex.getRuleTable` -> `Dex.formats.getRuleTable`
- `Dex.validateFormat` -> `Dex.formats.validate`

Team functions have been split off into a new `sim/teams` package:

- `Dex.packTeam` -> `Teams.pack`
- `Dex.fastUnpackTeam` -> `Teams.unpack`
- `Dex.generateTeam` -> `Teams.generate`
- `Dex.stringifyTeam` -> `Teams.export`

`Teams.export` has also been rewritten to better match how it works in client.

This implements #8178
2021-04-08 03:00:37 -07:00

77 lines
3.5 KiB
JavaScript

'use strict';
const assert = require('./../../assert');
const common = require('./../../common');
let battle;
describe('Comatose', function () {
afterEach(function () {
battle.destroy();
});
it('should make the user immune to status conditions', function () {
battle = common.createBattle();
battle.setPlayer('p1', {team: [{species: "Komala", ability: 'comatose', moves: ['shadowclaw']}]});
battle.setPlayer('p2', {team: [{species: "Smeargle", ability: 'noguard', moves: ['spore', 'glare', 'willowisp', 'toxic']}]});
const comatoseMon = battle.p1.active[0];
for (let i = 1; i <= 4; i++) {
assert.constant(() => comatoseMon.status, () => battle.makeChoices('move shadowclaw', 'move ' + i));
}
});
it('should not have its status immunity bypassed by Mold Breaker', function () {
battle = common.createBattle();
battle.setPlayer('p1', {team: [{species: "Komala", ability: 'comatose', moves: ['shadowclaw']}]});
battle.setPlayer('p2', {team: [{species: "Smeargle", ability: 'moldbreaker', moves: ['spore', 'glare', 'willowisp', 'toxic']}]});
const comatoseMon = battle.p1.active[0];
for (let i = 1; i <= 4; i++) {
assert.constant(() => comatoseMon.status, () => battle.makeChoices('move shadowclaw', 'move ' + i));
}
});
it('should cause Rest to fail', function () {
battle = common.createBattle();
battle.setPlayer('p1', {team: [{species: "Komala", ability: 'comatose', moves: ['rest']}]});
battle.setPlayer('p2', {team: [{species: "Smeargle", ability: 'technician', moves: ['aquajet']}]});
const comatoseMon = battle.p1.active[0];
assert.hurts(comatoseMon, () => battle.makeChoices('move rest', 'move aquajet'));
assert.constant(() => comatoseMon.status, () => battle.makeChoices('move rest', 'move aquajet'));
});
it('should allow the use of Snore and Sleep Talk as if the user were asleep', function () {
battle = common.createBattle([[
{species: "Komala", item: 'normaliumz', ability: 'comatose', moves: ['snore', 'sleeptalk', 'brickbreak']},
], [
{species: "Smeargle", moves: ['endure']},
]]);
const defender = battle.p2.active[0];
assert.hurts(defender, () => battle.makeChoices('move snore', 'move endure'), "Expected damage from Snore.");
assert.hurts(defender, () => battle.makeChoices('move sleeptalk', 'move endure'), "Expected damage from Sleep Talk calling Brick Break.");
});
it('should cause the user to be damaged by Dream Eater as if it were asleep', function () {
battle = common.createBattle();
battle.setPlayer('p1', {team: [{species: "Komala", ability: 'comatose', moves: ['shadowclaw']}]});
battle.setPlayer('p2', {team: [{species: "Smeargle", ability: 'technician', moves: ['dreameater']}]});
assert.hurts(battle.p1.active[0], () => battle.makeChoices('move shadowclaw', 'move dreameater'));
});
it('should cause Wake-Up Slap and Hex to have doubled base power when used against the user', function () {
battle = common.createBattle();
battle.setPlayer('p1', {team: [{species: "Komala", ability: 'comatose', item: 'ringtarget', moves: ['endure']}]});
battle.setPlayer('p2', {team: [{species: "Smeargle", ability: 'technician', moves: ['hex', 'wakeupslap']}]});
let bp = 0;
battle.onEvent('BasePower', battle.format, function (basePower, pokemon, target, move) {
bp = basePower;
});
battle.makeChoices('move endure', 'move hex');
assert.equal(bp, battle.dex.moves.get('hex').basePower * 2);
battle.makeChoices('move endure', 'move wakeupslap');
assert.equal(bp, battle.dex.moves.get('wakeupslap').basePower * 2);
});
});