From 5d04c4f2e0fd6b2c8798e8fd51bfec2e4f5c8fff Mon Sep 17 00:00:00 2001 From: Ivo Julca Date: Fri, 18 Nov 2016 12:48:50 -0500 Subject: [PATCH] King's Shield Atk drop now triggers even if immune --- data/moves.js | 10 +++++-- mods/gen6/moves.js | 27 +++++++++++++++++++ test/simulator/moves/kingsshield.js | 41 +++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 test/simulator/moves/kingsshield.js diff --git a/data/moves.js b/data/moves.js index 8232ded34d..f1d4c173d8 100644 --- a/data/moves.js +++ b/data/moves.js @@ -8780,8 +8780,8 @@ exports.BattleMovedex = { accuracy: true, basePower: 0, category: "Status", - desc: "The user is protected from most attacks made by other Pokemon during this turn, and Pokemon making contact with the user have their Attack lowered by 2 stages. Non-damaging moves go through this protection. This move has a 1/X chance of being successful, where X starts at 1 and triples each time this move is successfully used. X resets to 1 if this move fails or if the user's last move used is not Detect, Endure, King's Shield, Protect, Quick Guard, Spiky Shield, or Wide Guard. Fails if the user moves last this turn.", - shortDesc: "Protects from attacks. Contact: lowers Atk by 2.", + desc: "The user is protected from most attacks made by other Pokemon during this turn, and Pokemon trying to make contact with the user have their Attack lowered by 2 stages. Non-damaging moves go through this protection. This move has a 1/X chance of being successful, where X starts at 1 and triples each time this move is successfully used. X resets to 1 if this move fails or if the user's last move used is not Detect, Endure, King's Shield, Protect, Quick Guard, Spiky Shield, or Wide Guard. Fails if the user moves last this turn.", + shortDesc: "Protects from attacks. Contact try: lowers Atk by 2.", id: "kingsshield", isViable: true, name: "King's Shield", @@ -8801,6 +8801,12 @@ exports.BattleMovedex = { onStart: function (target) { this.add('-singleturn', target, 'Protect'); }, + onSourcePrepareHit: function (source, target, effect) { + if (effect.effectType !== 'Move' || !effect.flags['protect'] || effect.category === 'Status') return; + if (effect.flags['contact']) { + effect.ignoreImmunity = true; + } + }, onTryHitPriority: 3, onTryHit: function (target, source, move) { if (!move.flags['protect'] || move.category === 'Status') return; diff --git a/mods/gen6/moves.js b/mods/gen6/moves.js index a79297b931..da5487dc7b 100644 --- a/mods/gen6/moves.js +++ b/mods/gen6/moves.js @@ -48,6 +48,33 @@ exports.BattleMovedex = { inherit: true, basePower: 80, }, + kingsshield: { + inherit: true, + desc: "The user is protected from most attacks made by other Pokemon during this turn, and Pokemon trying to make contact with the user have their Attack lowered by 2 stages. Non-damaging moves go through this protection. This move has a 1/X chance of being successful, where X starts at 1 and triples each time this move is successfully used. X resets to 1 if this move fails or if the user's last move used is not Detect, Endure, King's Shield, Protect, Quick Guard, Spiky Shield, or Wide Guard. Fails if the user moves last this turn.", + shortDesc: "Protects from attacks. Contact try: lowers Atk by 2.", + effect: { + duration: 1, + onStart: function (target) { + this.add('-singleturn', target, 'Protect'); + }, + onTryHitPriority: 3, + onTryHit: function (target, source, move) { + if (!move.flags['protect'] || move.category === 'Status') return; + this.add('-activate', target, 'move: Protect'); + let lockedmove = source.getVolatile('lockedmove'); + if (lockedmove) { + // Outrage counter is reset + if (source.volatiles['lockedmove'].duration === 2) { + delete source.volatiles['lockedmove']; + } + } + if (move.flags['contact']) { + this.boost({atk:-2}, source, target, this.getMove("King's Shield")); + } + return null; + }, + }, + }, leechlife: { inherit: true, basePower: 20, diff --git a/test/simulator/moves/kingsshield.js b/test/simulator/moves/kingsshield.js new file mode 100644 index 0000000000..9bed5e73d1 --- /dev/null +++ b/test/simulator/moves/kingsshield.js @@ -0,0 +1,41 @@ +'use strict'; + +const assert = require('./../../assert'); +const common = require('./../../common'); + +let battle; + +describe(`King's Shield`, function () { + afterEach(() => battle.destroy()); + + it(`should lower the Atk of a contactor in 2 levels`, function () { + battle = common.createBattle([ + [{species: "Gallade", ability: 'justified', moves: ['zenheadbutt']}], + [{species: "Aegislash", ability: 'stancechange', moves: ['kingsshield']}], + ]); + battle.commitDecisions(); + assert.statStage(battle.p1.active[0], 'atk', -2); + }); + + it(`should lower the Atk of a contact-move attacker in 2 levels even if immune`, function () { + battle = common.createBattle([ + [{species: "Gallade", ability: 'justified', moves: ['drainpunch']}], + [{species: "Aegislash", ability: 'stancechange', moves: ['kingsshield']}], + ]); + battle.commitDecisions(); + assert.statStage(battle.p1.active[0], 'atk', -2); + }); +}); + +describe(`King's Shield [Gen 6]`, function () { + afterEach(() => battle.destroy()); + + it(`should not lower the Atk of a contact-move attacker if immune`, function () { + battle = common.gen(6).createBattle([ + [{species: "Gallade", ability: 'justified', moves: ['drainpunch']}], + [{species: "Aegislash", ability: 'stancechange', moves: ['kingsshield']}], + ]); + battle.commitDecisions(); + assert.statStage(battle.p1.active[0], 'atk', 0); + }); +});