mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-05-21 14:59:50 -05:00
This enables battles in tests to reset their RNG to what it originally
was when they were created. A number of tests do this already by
breaking encapsulating and modifying the prng variable directly. This
should fix that.
We also remove createBattleWithPRNG and min/maxSeed properties.
Firstly, the tests that were still using the maxSeed property were
setting it to Battle.seed which has no effect since the PRNG class does
not look at this property any more - so these were no-ops.
After removing this property from tests, maxRollSeed was never used, so
I removed it and renamed minRollSeed to DEFAULT_ROLL_SEED (since it's
constant).
The places that were still using minRollSeed also were no-ops or were
using createBattleWithPRNG. Since every single instance was actually
just using the same code, I removed createBattleWithPRNG and made
createBattle default to giving you a seed with DEFAULT_ROLL_SEED and
removed the minRollSeed property too.
This makes tests much simpler and reduces the usage surface of
TestTools; now, you must define your *own* seed if you're making a PRNG
for a test, or you use one that TestTools gives you; you may not use a
public property that TestTools gives you.
We also remove the code that removes a listener in the Battle Engine.
This was rendered obsolete by f6a7c4b (see more info [in the discussion
on github][disc]
[disc]:
https://github.com/Zarel/Pokemon-Showdown/pull/3272#discussion_r102414795
41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('./../../assert');
|
|
const common = require('./../../common');
|
|
|
|
let battle;
|
|
|
|
describe('Multiscale', function () {
|
|
afterEach(function () {
|
|
battle.destroy();
|
|
});
|
|
|
|
it('should halve damage when it is at full health', function () {
|
|
battle = common.createBattle();
|
|
battle.join('p1', 'Guest 1', 1, [{species: "Dragonite", ability: 'multiscale', moves: ['splash']}]);
|
|
battle.join('p2', 'Guest 2', 1, [{species: "Gyarados", ability: 'moxie', moves: ['incinerate']}]);
|
|
let damage, curhp;
|
|
let pokemon = battle.p1.active[0];
|
|
battle.commitDecisions();
|
|
damage = pokemon.maxhp - pokemon.hp;
|
|
curhp = pokemon.hp;
|
|
battle.resetRNG();
|
|
battle.commitDecisions();
|
|
assert.strictEqual(damage, battle.modify(curhp - pokemon.hp, 0.5));
|
|
});
|
|
|
|
it('should be suppressed by Mold Breaker', function () {
|
|
battle = common.createBattle();
|
|
battle.join('p1', 'Guest 1', 1, [{species: "Dragonite", ability: 'multiscale', moves: ['splash']}]);
|
|
battle.join('p2', 'Guest 2', 1, [{species: "Gyarados", ability: 'moldbreaker', moves: ['incinerate']}]);
|
|
let damage, curhp;
|
|
let pokemon = battle.p1.active[0];
|
|
battle.commitDecisions();
|
|
damage = pokemon.maxhp - pokemon.hp;
|
|
curhp = pokemon.hp;
|
|
battle.resetRNG();
|
|
battle.commitDecisions();
|
|
assert.strictEqual(curhp - pokemon.hp, damage);
|
|
});
|
|
});
|