From dd80e383220e7993b4803283091394fe06f5c79f Mon Sep 17 00:00:00 2001 From: Kevin Lau Date: Sun, 10 May 2015 01:33:25 -0700 Subject: [PATCH 1/2] Upgrade tests - Improve the wording on tests for status moves to be more clear - Add a test for Stealth Rocks --- test/simulator/misc/statusmoves.js | 48 ++++++++++++++++++++--------- test/simulator/moves/stealthrock.js | 22 +++++++++++++ 2 files changed, 56 insertions(+), 14 deletions(-) diff --git a/test/simulator/misc/statusmoves.js b/test/simulator/misc/statusmoves.js index 6f8865b07a..3c0c0bf8c7 100644 --- a/test/simulator/misc/statusmoves.js +++ b/test/simulator/misc/statusmoves.js @@ -6,7 +6,7 @@ describe('Most status moves', function () { battle.destroy(); }); - it('should ignore type immunities', function () { + it('should ignore natural type immunities', function () { battle = BattleEngine.Battle.construct(); battle.join('p1', 'Guest 1', 1, [{species: "Smeargle", ability: 'prankster', item: 'leftovers', moves: ['gastroacid', 'glare', 'confuseray', 'sandattack']}]); battle.join('p2', 'Guest 2', 1, [ @@ -32,31 +32,51 @@ describe('Most status moves', function () { assert.strictEqual(battle.p2.active[0].boosts['accuracy'], -1); }); - it('should not ignore type immunities', function () { + it('should fail when the opposing Pokemon is immune to the status effect it sets', function () { battle = BattleEngine.Battle.construct(); - battle.join('p1', 'Guest 1', 1, [{species: "Smeargle", ability: 'compoundeyes', item: 'widelens', moves: ['thunderwave', 'willowisp', 'poisongas', 'toxic']}]); + battle.join('p1', 'Guest 1', 1, [{species: "Smeargle", ability: 'noguard', moves: ['thunderwave', 'willowisp', 'poisongas', 'toxic']}]); battle.join('p2', 'Guest 2', 1, [ - {species: "Landorus", ability: 'sandforce', moves: ['bulkup']}, {species: "Zapdos", ability: 'pressure', moves: ['charge']}, - {species: "Heatran", ability: 'flashfire', moves: ['sleeptalk']}, - {species: "Muk", ability: 'stickyhold', moves: ['sleeptalk']} + {species: "Emboar", ability: 'blaze', moves: ['sleeptalk']}, + {species: "Muk", ability: 'stench', moves: ['shadowsneak']} ]); battle.commitDecisions(); - battle.choose('p1', 'move 1'); - battle.choose('p2', 'move 1'); assert.strictEqual(battle.p2.active[0].status, ''); - battle.choose('p1', 'move 1'); + assert.ok(battle.log[battle.lastMoveLine + 1].startsWith('|-immune|')); + battle.choose('p1', 'move 2'); battle.choose('p2', 'switch 2'); assert.strictEqual(battle.p2.active[0].status, ''); - battle.choose('p1', 'move 2'); + assert.ok(battle.log[battle.lastMoveLine + 1].startsWith('|-immune|')); + battle.choose('p1', 'move 3'); battle.choose('p2', 'switch 3'); assert.strictEqual(battle.p2.active[0].status, ''); - battle.choose('p1', 'move 3'); - battle.choose('p2', 'switch 4'); - assert.strictEqual(battle.p2.active[0].status, ''); + assert.ok(battle.log[battle.lastMoveLine + 1].startsWith('|-immune|')); battle.choose('p1', 'move 4'); - battle.choose('p2', 'move 1'); + battle.commitDecisions(); assert.strictEqual(battle.p2.active[0].status, ''); + assert.ok(battle.log[battle.lastMoveLine + 1].startsWith('|-immune|')); }); }); +describe('Thunder Wave, poison-inflicting status moves', function () { + afterEach(function () { + battle.destroy(); + }); + + it('should not ignore type immunities', function () { + battle = BattleEngine.Battle.construct(); + battle.join('p1', 'Guest 1', 1, [{species: "Smeargle", ability: 'noguard', moves: ['thunderwave', 'poisongas', 'toxic']}]); + battle.join('p2', 'Guest 2', 1, [ + {species: "Hippowdon", ability: 'sandforce', moves: ['slackoff']}, + {species: "Registeel", ability: 'clearbody', moves: ['sleeptalk']} + ]); + battle.commitDecisions(); + assert.strictEqual(battle.p2.active[0].status, ''); + battle.choose('p1', 'move 2'); + battle.choose('p2', 'switch 2'); + assert.strictEqual(battle.p2.active[0].status, ''); + battle.choose('p1', 'move 2'); + battle.commitDecisions(); + assert.strictEqual(battle.p2.active[0].status, ''); + }); +}); diff --git a/test/simulator/moves/stealthrock.js b/test/simulator/moves/stealthrock.js index 51639405df..6dd372c696 100644 --- a/test/simulator/moves/stealthrock.js +++ b/test/simulator/moves/stealthrock.js @@ -13,4 +13,26 @@ describe('Stealth Rock', function () { battle.commitDecisions(); assert(battle.p2.sideConditions['stealthrock']); }); + + it('should deal damage to Pokemon switching in based on their type effectiveness against Rock-type', function () { + battle = BattleEngine.Battle.construct(); + battle.join('p1', 'Guest 1', 1, [{species: "Smeargle", moves: ['splash', 'stealthrock']}]); + battle.join('p2', 'Guest 2', 1, [ + {species: "Ninjask", moves: ['protect']}, + {species: "Volcarona", moves: ['roost']}, + {species: "Staraptor", moves: ['roost']}, + {species: "Chansey", moves: ['wish']}, + {species: "Hitmonchan", moves: ['rest']}, + {species: "Steelix", moves: ['rest']} + ]); + battle.choose('p1', 'move 2'); + battle.commitDecisions(); + var pokemon; + for (var i = 2; i <= 6; i++) { + battle.choose('p2', 'switch ' + i); + battle.commitDecisions(); + pokemon = battle.p2.active[0]; + assert.strictEqual(pokemon.maxhp - pokemon.hp, Math.floor(pokemon.maxhp * Math.pow(0.5, i - 1))); + } + }); }); From 93d5efef4399ada0292086021dce8737b4f603f9 Mon Sep 17 00:00:00 2001 From: Kevin Lau Date: Sun, 10 May 2015 15:40:59 -0700 Subject: [PATCH 2/2] Status moves return -immune if the target is immune to the status move --- data/scripts.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/scripts.js b/data/scripts.js index e62a32953b..a0076f2e38 100644 --- a/data/scripts.js +++ b/data/scripts.js @@ -455,6 +455,10 @@ exports.BattleScripts = { if (moveData.status) { if (!target.status) { hitResult = target.setStatus(moveData.status, pokemon, move); + if (!hitResult && move.status) { + this.add('-immune', target, '[msg]'); + return false; + } didSomething = didSomething || hitResult; } else if (!isSecondary) { if (target.status === moveData.status) {