mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-04-25 07:22:09 -05:00
Fix crash in Knock Off + Substitute
(This also fixes a bug where hitting Substitute procced DamagingHit events.)
This commit is contained in:
parent
ec5471872f
commit
ee4435716f
|
|
@ -805,7 +805,7 @@ let BattleScripts = {
|
|||
let damagedTargets = [];
|
||||
let damagedDamage = [];
|
||||
for (let i = 0; i < targets.length; i++) {
|
||||
if (typeof damage[i] === 'number') {
|
||||
if (typeof damage[i] === 'number' && targets[i]) {
|
||||
damagedTargets.push(/** @type {Pokemon} */ (targets[i]));
|
||||
damagedDamage.push(damage[i]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,14 @@ describe('Knock Off', function () {
|
|||
assert.strictEqual(battle.p2.active[0].item, '');
|
||||
});
|
||||
|
||||
it('should not remove items when hitting Sub', function () {
|
||||
battle = common.createBattle();
|
||||
battle.setPlayer('p1', {team: [{species: "Mew", ability: 'noability', moves: ['knockoff']}]});
|
||||
battle.setPlayer('p2', {team: [{species: "Ninjask", ability: 'noability', item: 'shedshell', moves: ['substitute']}]});
|
||||
battle.makeChoices();
|
||||
assert.strictEqual(battle.p2.active[0].item, 'shedshell');
|
||||
});
|
||||
|
||||
it('should not remove plates from Arceus', function () {
|
||||
battle = common.createBattle();
|
||||
battle.setPlayer('p1', {team: [{species: "Mew", ability: 'synchronize', moves: ['knockoff']}]});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user