pokemon-showdown/test/sim/abilities/parentalbond.js
Guangcong Luo 7a023746ba
Refactor battle.dex out of battle (#5851)
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 07:38:08 +11:00

69 lines
2.1 KiB
JavaScript

'use strict';
const assert = require('./../../assert');
const common = require('./../../common');
let battle;
let basePowers;
describe('Parental Bond', function () {
beforeEach(function () {
battle = common.createBattle([
[{species: 'Kangaskhan', ability: 'parentalbond', item: 'normaliumz', moves: ['falseswipe', 'doublehit']}],
[{species: 'Aggron', ability: 'noguard', moves: ['rest']}],
]);
basePowers = [];
battle.onEvent('BasePower', battle.format, -9, function (bp, attacker, defender, move) {
basePowers.push(this.modify(bp, this.event.modifier));
});
});
afterEach(function () {
battle.destroy();
});
it('should cause single-hit attacks to strike twice, with the second hit at 0.25 power', function () {
battle.makeChoices('move falseswipe', 'move rest');
assert.deepStrictEqual(basePowers, [40, 10]);
});
it('should not have any effect on moves with multiple hits', function () {
battle.makeChoices('move doublehit', 'move rest');
assert.deepStrictEqual(basePowers, [35, 35]);
});
it('should not have any effect Z-Moves', function () {
battle.makeChoices('move falseswipe zmove', 'move rest');
assert.deepStrictEqual(basePowers, [100]);
});
});
describe('Parental Bond [Gen 6]', function () {
beforeEach(function () {
battle = common.gen(6).createBattle([
[{species: 'Kangaskhan', ability: 'parentalbond', moves: ['falseswipe', 'doublehit']}],
[{species: 'Aggron', ability: 'noguard', moves: ['rest']}],
]);
basePowers = [];
battle.onEvent('BasePower', battle.format, -9, function (bp, attacker, defender, move) {
basePowers.push(this.modify(bp, this.event.modifier));
});
});
afterEach(function () {
battle.destroy();
});
it('should cause single-hit attacks to strike twice, with the second hit at 0.5 power', function () {
battle.makeChoices('move falseswipe', 'move rest');
assert.deepStrictEqual(basePowers, [40, 20]);
});
it('should not have any effect on moves with multiple hits', function () {
battle.makeChoices('move doublehit', 'move rest');
assert.deepStrictEqual(basePowers, [35, 35]);
});
});