pokemon-showdown/test/sim/abilities/shellarmor.js
Guangcong Luo 2d3614f325 Refactor battle.dex out of battle
In most other similar systems, like TeamValidator, we use `thing.dex`
instead of having it extend `ModdedDex`. Battle has always extended
`ModdedDex`, though. This changes Battle to match the others.

This should fix an issue with `Battle.data` not being cached.

This also frees up Battle to extend ObjectReadWriteStream<string> in
a future update.
2019-10-06 04:50:35 +11:00

45 lines
1.4 KiB
JavaScript

'use strict';
const assert = require('./../../assert');
const common = require('./../../common');
let battle;
describe('Shell Armor', function () {
afterEach(function () {
battle.destroy();
});
it('should prevent moves from dealing critical hits', function () {
battle = common.createBattle([
[{species: 'Slowbro', ability: 'shellarmor', moves: ['quickattack']}],
[{species: 'Cryogonal', ability: 'noguard', moves: ['frostbreath']}],
]);
let successfulEvent = false;
battle.onEvent('ModifyDamage', battle.format, function (damage, attacker, defender, move) {
if (move.id === 'frostbreath') {
successfulEvent = true;
assert.false(defender.getMoveHitData(move).crit);
}
});
battle.makeChoices('move quickattack', 'move frostbreath');
assert.ok(successfulEvent);
});
it('should be suppressed by Mold Breaker', function () {
battle = common.createBattle([
[{species: 'Slowbro', ability: 'shellarmor', moves: ['quickattack']}],
[{species: 'Cryogonal', ability: 'moldbreaker', item: 'zoomlens', moves: ['frostbreath']}],
]);
let successfulEvent = false;
battle.onEvent('ModifyDamage', battle.format, function (damage, attacker, defender, move) {
if (move.id === 'frostbreath') {
successfulEvent = true;
assert.ok(defender.getMoveHitData(move).crit);
}
});
battle.makeChoices('move quickattack', 'move frostbreath');
assert.ok(successfulEvent);
});
});