pokemon-showdown/test/simulator/abilities/flashfire.js
Dan Pantry 9c65c5b84a add mock for battle tests that can reset the RNG
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
2017-02-22 20:44:20 -05:00

64 lines
2.7 KiB
JavaScript

'use strict';
const assert = require('./../../assert');
const common = require('./../../common');
let battle;
describe('Flash Fire', function () {
afterEach(function () {
battle.destroy();
});
it('should grant immunity to Fire-type moves and increase Fire-type attacks by 50% once activated', function () {
battle = common.createBattle();
const p1 = battle.join('p1', 'Guest 1', 1, [{species: 'Heatran', ability: 'flashfire', moves: ['incinerate']}]);
const p2 = battle.join('p2', 'Guest 2', 1, [{species: 'Talonflame', ability: 'galewings', moves: ['flareblitz']}]);
battle.commitDecisions();
assert.fullHP(p1.active[0]);
let damage = p2.active[0].maxhp - p2.active[0].hp;
assert.bounded(damage, [82, 97]);
});
it('should grant Fire-type immunity even if the user is frozen', function () {
battle = common.createBattle();
const p1 = battle.join('p1', 'Guest 1', 1, [{species: 'Heatran', ability: 'flashfire', moves: ['sleeptalk']}]);
battle.join('p2', 'Guest 2', 1, [{species: 'Talonflame', ability: 'galewings', moves: ['flareblitz']}]);
p1.active[0].setStatus('frz');
assert.false.hurts(p1.active[0], () => battle.commitDecisions());
});
it('should have its Fire-type immunity suppressed by Mold Breaker', function () {
battle = common.createBattle();
battle.join('p1', 'Guest 1', 1, [{species: 'Heatran', ability: 'flashfire', moves: ['incinerate']}]);
battle.join('p2', 'Guest 2', 1, [{species: 'Haxorus', ability: 'moldbreaker', moves: ['firepunch']}]);
assert.hurts(battle.p1.active[0], () => battle.commitDecisions());
});
it('should lose the Flash Fire boost if its ability is changed', function () {
battle = common.createBattle();
battle.join('p1', 'Guest 1', 1, [{species: 'Heatran', ability: 'flashfire', moves: ['sleeptalk', 'incinerate']}]);
const p2 = battle.join('p2', 'Guest 2', 1, [{species: 'Talonflame', ability: 'galewings', moves: ['incinerate', 'worryseed']}]);
battle.commitDecisions();
battle.resetRNG();
p2.chooseMove('worryseed').foe.chooseMove('incinerate');
let damage = battle.p2.active[0].maxhp - battle.p2.active[0].hp;
assert.bounded(damage, [54, 65]);
});
});
describe('Flash Fire [Gen 4]', function () {
afterEach(function () {
battle.destroy();
});
// TODO: Check if this is actually a behavior in Gen 3-4
it.skip('should grant Fire-type immunity even if the user is frozen', function () {
battle = common.createBattle();
const p1 = battle.join('p1', 'Guest 1', 1, [{species: 'Heatran', ability: 'flashfire', moves: ['sleeptalk']}]);
battle.join('p2', 'Guest 2', 1, [{species: 'Charizard', ability: 'blaze', moves: ['flamethrower']}]);
p1.active[0].setStatus('frz');
assert.false.hurts(p1.active[0], () => battle.commitDecisions());
});
});