File size: 5,616 Bytes
5c2ed06
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
'use strict';

const assert = require('./../../assert');
const common = require('./../../common');

let battle;

describe('Protective Pads', () => {
	afterEach(() => {
		battle.destroy();
	});

	it(`should prevent ability-changing abilities triggered by contact from acting`, () => {
		battle = common.createBattle([[
			{ species: 'wynaut', ability: 'sturdy', item: 'protectivepads', moves: ['bulletpunch'] },
		], [
			{ species: 'cofagrigus', ability: 'mummy', moves: ['sleeptalk'] },
		]]);

		const wynaut = battle.p1.active[0];
		battle.makeChoices();
		assert.equal(wynaut.ability, 'sturdy');
		const mummyActivationMessages = battle.log.filter(logStr => logStr.startsWith('|-activate|') && logStr.includes('Mummy'));
		assert.equal(mummyActivationMessages.length, 1, `Mummy should activate only once`);
		assert(mummyActivationMessages[0].includes('Cofagrigus'), `Source of Mummy activation should be included`);
		assert.false(mummyActivationMessages[0].includes('Sturdy'), `Attacker's ability should not be revealed`);
	});

	it(`should prevent damaging abilities triggered by contact from acting`, () => {
		battle = common.createBattle([[
			{ species: 'wynaut', item: 'protectivepads', moves: ['bulletpunch'] },
		], [
			{ species: 'ferrothorn', ability: 'ironbarbs', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		assert.fullHP(battle.p1.active[0], `Attacker should not be damaged`);
		assert(battle.log.some(line => line.includes('Iron Barbs')));
		assert(battle.log.some(line => line.includes('Protective Pads')));
	});

	it(`should prevent stat stage-changing abilities triggered by contact from acting`, () => {
		battle = common.createBattle([[
			{ species: 'wynaut', item: 'protectivepads', moves: ['bulletpunch'] },
		], [
			{ species: 'goodra', ability: 'gooey', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		assert.statStage(battle.p1.active[0], 'spe', 0, `Speed should not be lowered`);
		assert(battle.log.some(line => line.includes('Gooey')));
		assert(battle.log.some(line => line.includes('Protective Pads')));
	});

	it(`should not stop Pickpocket`, () => {
		battle = common.createBattle([[
			{ species: 'wynaut', item: 'protectivepads', moves: ['bulletpunch'] },
		], [
			{ species: 'weavile', ability: 'pickpocket', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		assert.false.holdsItem(battle.p1.active[0], `Attacker should lose their item`);
		assert.equal(battle.p2.active[0].item, 'protectivepads', `Target should receive stolen Protective Pads`);
	});

	it(`should prevent item effects triggered by contact from acting`, () => {
		battle = common.createBattle([[
			{ species: 'wynaut', item: 'protectivepads', moves: ['bulletpunch'] },
		], [
			{ species: 'miltank', item: 'rockyhelmet', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		assert.fullHP(battle.p1.active[0], `Attacker should not be hurt`);
		assert(battle.log.every(line => !line.includes('Rocky Helmet')));
		assert(battle.log.every(line => !line.includes('Protective Pads')));
	});

	it(`should not activate on the opponent's moves`, () => {
		battle = common.createBattle([[
			{ species: 'wynaut', item: 'protectivepads', moves: ['sleeptalk'] },
		], [
			{ species: 'happiny', moves: ['lunge'] },
		]]);
		battle.makeChoices();
		assert.statStage(battle.p1.active[0], 'atk', -1, `Attack should be lowered`);
	});

	it(`should not start Perish Body on either Pokemon`, () => {
		battle = common.createBattle([[
			{ species: 'wynaut', item: 'protectivepads', moves: ['bulletpunch'] },
		], [
			{ species: 'cursola', ability: 'perishbody', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		assert.false(battle.p1.active[0].volatiles['perishsong'], 'Perish Body should not have activated on Wynaut due to Protective Pads.');
		assert.false(battle.p2.active[0].volatiles['perishsong'], 'Perish Body should not have activated on Cursola due to Protective Pads.');
		assert(battle.log.every(line => !line.includes('Perish Body')));
		assert(battle.log.every(line => !line.includes('Protective Pads')));
	});

	it(`should block against Protecting effects with a contact side effect`, () => {
		battle = common.createBattle([[
			{ species: 'wynaut', item: 'protectivepads', moves: ['sleeptalk', 'tackle'] },
		], [
			{ species: 'aggron', moves: ['sleeptalk', 'banefulbunker', 'obstruct', 'spikyshield'] },
		]]);
		battle.makeChoices('move tackle', 'move banefulbunker');
		battle.makeChoices();
		battle.makeChoices('move tackle', 'move obstruct');
		battle.makeChoices();
		battle.makeChoices('move tackle', 'move spikyshield');
		battle.makeChoices();
		const wynaut = battle.p1.active[0];
		assert.equal(wynaut.status, '', `Wynaut should not have been poisoned by Baneful Bunker`);
		assert.statStage(wynaut, 'def', 0, `Wynaut's Defense should not have been lowered by Obstruct`);
		assert.fullHP(wynaut, `Wynaut should not have lost HP from Spiky Shield`);
		assert(battle.log.every(line => !line.includes('Protective Pads')));
	});

	it(`should not protect against Gulp Missile when using a contact move`, () => {
		battle = common.createBattle([[
			{ species: 'wynaut', item: 'protectivepads', moves: ['bulletpunch'] },
		], [
			{ species: 'cramorantgorging', ability: 'gulpmissile', item: 'rockyhelmet', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		const wynaut = battle.p1.active[0];
		assert.equal(wynaut.hp, wynaut.maxhp - Math.floor(wynaut.maxhp / 4), `Wynaut should be damaged by Gulp Missile, but not Rocky Helmet`);
		assert.equal(wynaut.status, 'par');
		assert(battle.log.every(line => !line.includes('Protective Pads')));
	});
});