Skip to content

Commit

Permalink
Don't skip residuals after fainting in Gen2.
Browse files Browse the repository at this point in the history
The original code was wrong, as all it did was skipping residuals.
Skipping moves is handled by `faintMessages`.
  • Loading branch information
KamilaBorowska committed Feb 21, 2015
1 parent 222b64f commit 815909e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
1 change: 0 additions & 1 deletion mods/gen2/scripts.js
Expand Up @@ -875,7 +875,6 @@ exports.BattleScripts = {
this.debug('instafaint: ' + this.faintQueue.map('target').map('name'));
this.faintMessages(true);
target.faint();
this.queue = [];
} else {
damage = this.runEvent('AfterDamage', target, source, effect, damage);
}
Expand Down
27 changes: 27 additions & 0 deletions test/simulator/items/leftovers.js
@@ -0,0 +1,27 @@
var assert = require('assert');
var battle;

describe('Leftovers - GSC', function () {
afterEach(function () {
battle.destroy();
});

it('should heal after switch', function () {
battle = BattleEngine.Battle.construct('battle-leftovers-gsc', 'gen2customgame');
battle.join('p1', 'Guest 1', 1, [
{species: 'Blissey', item: 'leftovers', moves: ['healbell']},
{species: 'Magikarp', level: 1, moves: ['splash']}
]);
battle.join('p2', 'Guest 2', 1, [
{species: "Miltank", moves: ['seismictoss']}
]);
battle.commitDecisions();
assert.strictEqual(battle.p1.active[0].hp, 614);

battle.choose('p1', 'switch 2');
battle.commitDecisions();

battle.choose('p1', 'switch 2');
assert.strictEqual(battle.p1.active[0].hp, 656);
});
});

1 comment on commit 815909e

@Joimer
Copy link
Contributor

@Joimer Joimer commented on 815909e Feb 21, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice test btw

Please sign in to comment.