King's Shield Atk drop now triggers even if immune

This commit is contained in:
Ivo Julca 2016-11-18 12:48:50 -05:00
parent 6b6de3e98e
commit 5d04c4f2e0
3 changed files with 76 additions and 2 deletions

View File

@ -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;

View File

@ -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,

View File

@ -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);
});
});