diff --git a/test/common.js b/test/common.js index c828cb341b2a..912d527efc64 100644 --- a/test/common.js +++ b/test/common.js @@ -95,17 +95,19 @@ class TestTools { * * @param {Object} [options] * @param {Team[]} [teams] - * @param {PRNG} [prng] A pseudo-random number generator. If not provided, a pseudo-random number - * generator will be generated for the user with a seed that is guaranteed to be the same across - * test executions to help with determinism. * @returns {Sim.Battle} A battle. */ - createBattle(options, teams, prng = new PRNG(DEFAULT_SEED)) { + createBattle(options, teams) { if (Array.isArray(options)) { teams = options; options = {}; } - const format = this.getFormat(options || {}); + if (!options) options = {}; + // If a seed for the pseudo-random number generator is not provided, + // a default seed (guaranteed to be the same across test executions) + // will be used. The default seed is intentionally tuned + let prng = new PRNG(options.seed || DEFAULT_SEED); + const format = this.getFormat(options); const battle = Sim.construct( format.id, undefined, diff --git a/test/simulator/abilities/dancer.js b/test/simulator/abilities/dancer.js index d000c8ac3141..59a8f3e3337c 100644 --- a/test/simulator/abilities/dancer.js +++ b/test/simulator/abilities/dancer.js @@ -2,7 +2,6 @@ const assert = require('./../../assert'); const common = require('./../../common'); -const PRNG = require('./../../../sim/prng'); let battle; @@ -55,7 +54,7 @@ describe('Dancer', function () { }); it('should not copy a move that failed or was blocked by Protect', function () { - battle = common.createBattle({gameType: 'doubles'}, null, new PRNG([1, 2, 3, 4])); + battle = common.createBattle({gameType: 'doubles', seed: [1, 2, 3, 4]}); const p1 = battle.join('p1', 'Guest 1', 1, [ {species: 'Oricorio', level: 98, ability: 'dancer', item: 'laggingtail', moves: ['dragondance', 'protect', 'teeterdance']}, {species: 'Oricorio', level: 99, ability: 'dancer', moves: ['featherdance']}, @@ -90,7 +89,7 @@ describe('Dancer', function () { }); it('should not copy a move that missed', function () { - battle = common.createBattle({gameType: 'singles'}, null, new PRNG([1, 2, 3, 4])); + battle = common.createBattle({gameType: 'singles', seed: [1, 2, 3, 4]}); const p1 = battle.join('p1', 'Guest 1', 1, [{species: 'Oricorio', ability: 'dancer', item: 'choicescarf', moves: ['revelationdance']}]); const p2 = battle.join('p2', 'Guest 2', 1, [{species: 'Oricorio', ability: 'dancer', item: 'brightpowder', moves: ['dig']}]); p1.active[0].boostBy({accuracy: -6}); diff --git a/test/simulator/moves/miracleeye.js b/test/simulator/moves/miracleeye.js index ff143fab7e8c..a4c6bbadc328 100644 --- a/test/simulator/moves/miracleeye.js +++ b/test/simulator/moves/miracleeye.js @@ -11,37 +11,41 @@ describe('Miracle Eye', function () { }); it('should negate Psychic immunities', function () { - battle = common.createBattle(); - battle.join('p1', 'Guest 1', 1, [{species: "Smeargle", ability: 'owntempo', moves: ['miracleeye', 'psychic']}]); - battle.join('p2', 'Guest 2', 1, [{species: "Darkrai", ability: 'baddreams', moves: ['nastyplot']}]); - battle.commitDecisions(); - battle.choose('p1', 'move 2'); - battle.commitDecisions(); + battle = common.createBattle({seed: [1, 2, 3, 4]}, [[ + {species: "Smeargle", moves: ['miracleeye', 'psychic']}, + ], [ + {species: "Darkrai", moves: ['nastyplot']}, + ]]); + battle.makeChoices('move miracle eye', 'move nasty plot'); + battle.makeChoices('move psychic', 'move nasty plot'); assert.notStrictEqual(battle.p2.active[0].hp, battle.p2.active[0].maxhp); }); it('should ignore the effect of positive evasion stat stages', function () { - battle = common.createBattle(); - battle.join('p1', 'Guest 1', 1, [{species: "Smeargle", ability: 'owntempo', moves: ['avalanche', 'miracleeye']}]); - battle.join('p2', 'Guest 2', 1, [{species: "Forretress", ability: 'sturdy', moves: ['synthesis']}]); - battle.choose('p1', 'move 2'); - battle.commitDecisions(); + battle = common.createBattle({seed: [1, 2, 3, 4]}, [[ + {species: "Smeargle", moves: ['avalanche', 'miracleeye']}, + ], [ + {species: "Forretress", moves: ['synthesis']}, + ]]); + battle.makeChoices('move miracle eye', 'move synthesis'); battle.boost({evasion: 6}, battle.p2.active[0]); - for (let i = 0; i < 16; i++) { - battle.commitDecisions(); + for (let i = 0; i < 3; i++) { + battle.makeChoices('move avalanche', 'move synthesis'); assert.notStrictEqual(battle.p2.active[0].hp, battle.p2.active[0].maxhp); } }); it('should not ignore the effect of negative evasion stat stages', function () { - battle = common.createBattle(); - battle.join('p1', 'Guest 1', 1, [{species: "Smeargle", ability: 'owntempo', moves: ['zapcannon', 'dynamicpunch', 'miracleeye']}]); - battle.join('p2', 'Guest 2', 1, [{species: "Zapdos", ability: 'owntempo', moves: ['roost']}]); + battle = common.createBattle({seed: [1, 2, 3, 4]}, [[ + {species: "Smeargle", moves: ['zapcannon', 'miracleeye']}, + ], [ + {species: "Zapdos", moves: ['roost']}, + ]]); battle.choose('p1', 'move 3'); - battle.commitDecisions(); + battle.makeChoices('move miracle eye', 'move roost'); battle.boost({spe: 6, evasion: -6}, battle.p2.active[0]); - for (let i = 0; i < 16; i++) { - battle.commitDecisions(); + for (let i = 0; i < 3; i++) { + battle.makeChoices('move zap cannon', 'move roost'); assert.notStrictEqual(battle.p2.active[0].hp, battle.p2.active[0].maxhp); } });