pokemon-showdown/test/sim/misc/zmoves.js
Guangcong Luo ed454ef76a
Refactor scripts to battle-actions (#8138)
This introduces a new class, BattleActions, available as `battle.actions`,
moving all functions from `data/scripts.ts` to `sim/battle-actions.ts`.

This makes it so that "go to definition" will now work correctly for
functions previously in scripts; we no longer need UnimplementedError,
and there's now a clean conceptual separation between `battle` and
`battle-actions` (whereas the previous distinction between `battle` and
`scripts` was basically nonexistent).

This will be a difficult migration if you maintain a fork with custom
scripted mods. I'm sorry! Migration instructions are here:

https://github.com/smogon/pokemon-showdown/pull/8138
2021-03-28 12:01:38 -07:00

42 lines
1.5 KiB
JavaScript

'use strict';
const assert = require('./../../assert');
const common = require('./../../common');
let battle;
describe('Z Moves', function () {
afterEach(function () {
battle.destroy();
});
it(`should be possible to activate them when the base move is disabled`, function () {
battle = common.createBattle([
[{species: "Chansey", item: 'normaliumz', ability: 'naturalcure', moves: ['doubleteam', 'fireblast']}],
[{species: "Mightyena", ability: 'intimidate', moves: ['taunt']}],
]);
const chansey = battle.p1.active[0];
assert.statStage(chansey, 'atk', -1);
battle.makeChoices('auto', 'move taunt');
assert(battle.actions.canZMove(chansey), `Chansey should be able to use its Z Move`);
battle.makeChoices('move doubleteam zmove', 'auto'); // Z-Effect: Restores negative stat stages to 0
assert.statStage(chansey, 'atk', 0);
});
it(`should be impossible to activate them when all the base moves are disabled`, function () {
battle = common.createBattle([
[{species: "Chansey", item: 'normaliumz', ability: 'naturalcure', moves: ['doubleteam', 'minimize']}],
[{species: "Mightyena", ability: 'intimidate', moves: ['taunt']}],
]);
const chansey = battle.p1.active[0];
assert.statStage(chansey, 'atk', -1);
battle.makeChoices('auto', 'move taunt');
assert.false(battle.actions.canZMove(chansey), `Chansey should not be able to use its Z Move`);
battle.makeChoices('auto', 'auto');
assert.statStage(chansey, 'atk', -1);
assert.cantMove(() => battle.makeChoices('move doubleteam zmove', ''));
});
});