File size: 9,523 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
'use strict';

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

let battle;

describe('Dragon Darts', () => {
	afterEach(() => {
		battle.destroy();
	});

	it(`should hit twice in singles`, () => {
		battle = common.createBattle([[
			{ species: "Ninjask", moves: ['dragondarts'] },
		], [
			{ species: "Mew", ability: 'stamina', moves: ['splash'] },
		]]);
		battle.makeChoices();
		assert.statStage(battle.p2.active[0], 'def', 2);
	});

	it(`should hit each foe once in doubles`, () => {
		battle = common.createBattle({ gameType: 'doubles' }, [[
			{ species: "Ninjask", moves: ['dragondarts'] },
			{ species: "Mew", ability: 'stamina', moves: ['splash'] },
		], [
			{ species: "Mew", ability: 'stamina', moves: ['splash'] },
			{ species: "Mew", ability: 'stamina', moves: ['splash'] },
		]]);
		battle.makeChoices();
		assert.statStage(battle.p1.active[1], 'def', 0);
		assert.statStage(battle.p2.active[0], 'def', 1);
		assert.statStage(battle.p2.active[1], 'def', 1);
	});

	it(`should hit the other foe twice if it misses against one`, () => {
		battle = common.createBattle({ gameType: 'doubles' }, [[
			{ species: "Ninjask", item: 'blunderpolicy', moves: ['dragondarts'] },
			{ species: "Wynaut", ability: 'stamina', moves: ['splash'] },
		], [
			{ species: "Mew", ability: 'stamina', moves: ['splash'] },
			{ species: "Shaymin", ability: 'stamina', moves: ['splash'] },
		]]);

		const ninjask = battle.p1.active[0];
		const wynaut = battle.p1.active[1];
		const mew = battle.p2.active[0];
		const shaymin = battle.p2.active[1];

		// Modding accuracy so Dragon Darts always misses Mew
		battle.onEvent('Accuracy', battle.format, (accuracy, target, source, move) => {
			return target.species.id !== 'mew';
		});

		battle.makeChoices();
		assert.false(battle.log.includes('|-miss|p1a: Ninjask|p2a: Mew'));
		assert.statStage(ninjask, 'spe', 2);
		assert.statStage(wynaut, 'def', 0);
		assert.statStage(mew, 'def', 0);
		assert.statStage(shaymin, 'def', 2);
	});

	it(`should hit itself and ally if it targets itself after Ally Switch`, () => {
		battle = common.createBattle({ gameType: 'doubles' }, [[
			{ species: "Ninjask", ability: 'stamina', moves: ['dragondarts'] },
			{ species: "Mew", ability: 'stamina', moves: ['allyswitch'] },
		], [
			{ species: "Mew", ability: 'stamina', moves: ['splash'] },
			{ species: "Shaymin", ability: 'stamina', moves: ['splash'] },
		]]);
		battle.makeChoices('move dragondarts -2, move allyswitch', 'move splash, move splash');
		assert.statStage(battle.p1.active[0], 'def', 1);
		assert.statStage(battle.p1.active[1], 'def', 1);
		assert.statStage(battle.p2.active[0], 'def', 0);
		assert.statStage(battle.p2.active[1], 'def', 0);
	});

	it(`should hit both targets even if one faints`, () => {
		battle = common.createBattle({ gameType: 'doubles' }, [[
			{ species: "Ninjask", moves: ['dragondarts'] },
			{ species: "Mew", moves: ['splash'] },
		], [
			{ species: "Shedinja", moves: ['splash'] },
			{ species: "Shedinja", moves: ['splash'] },
		]]);
		battle.makeChoices();
		battle.getDebugLog();
		assert.equal(battle.p2.active[0].hp, 0);
		assert.equal(battle.p2.active[1].hp, 0);
	});

	it(`should hit the ally twice in doubles`, () => {
		battle = common.createBattle({ gameType: 'doubles' }, [[
			{ species: "Ninjask", moves: ['dragondarts'] },
			{ species: "Mew", ability: 'stamina', moves: ['splash'] },
		], [
			{ species: "Mew", ability: 'stamina', moves: ['splash'] },
			{ species: "Mew", ability: 'stamina', moves: ['splash'] },
		]]);
		battle.makeChoices('move dragondarts -2, move splash', 'move splash, move splash');
		assert.statStage(battle.p1.active[1], 'def', 2);
		assert.statStage(battle.p2.active[0], 'def', 0);
		assert.statStage(battle.p2.active[1], 'def', 0);
	});

	it(`should smart-target the foe that's not Protecting in Doubles`, () => {
		battle = common.createBattle({ gameType: 'doubles' }, [[
			{ species: "Ninjask", moves: ['dragondarts'] },
			{ species: "Mew", ability: 'stamina', moves: ['splash'] },
		], [
			{ species: "Mew", ability: 'stamina', moves: ['protect'] },
			{ species: "Mew", ability: 'stamina', moves: ['splash'] },
		]]);
		battle.makeChoices();
		assert.statStage(battle.p1.active[1], 'def', 0);
		assert.statStage(battle.p2.active[0], 'def', 0);
		assert.statStage(battle.p2.active[1], 'def', 2);
	});

	it(`should be able to be redirected`, () => {
		battle = common.createBattle({ gameType: 'doubles' }, [[
			{ species: "Ninjask", moves: ['dragondarts'] },
			{ species: "Mew", ability: 'stamina', moves: ['splash'] },
		], [
			{ species: "Mew", ability: 'stamina', moves: ['ragepowder'] },
			{ species: "Mew", ability: 'stamina', moves: ['splash'] },
		]]);
		battle.makeChoices();
		assert.statStage(battle.p1.active[1], 'def', 0);
		assert.statStage(battle.p2.active[0], 'def', 2);
		assert.statStage(battle.p2.active[1], 'def', 0);
	});

	it('should hit one target twice if the other is protected by an ability', () => {
		battle = common.createBattle({ gameType: 'doubles' });
		battle.setPlayer('p1', { team: [
			{ species: "Dragapult", ability: "Clear Body", moves: ["dragondarts"] },
			{ species: "Grimmsnarl", ability: "Prankster", moves: ["electrify"] },
		] });
		battle.setPlayer('p2', { team: [
			{ species: "Arcanine", ability: "Stamina", moves: ["sleeptalk"] },
			{ species: "Emolga", ability: "Motor Drive", moves: ["sleeptalk"] },
		] });
		battle.makeChoices('move dragondarts 2, move electrify -1', 'move sleeptalk, move sleeptalk');

		assert.notEqual(battle.p2.active[0].hp, battle.p2.active[0].maxhp);
		assert.equal(battle.p2.active[1].hp, battle.p2.active[1].maxhp);
		assert.statStage(battle.p2.active[0], 'def', 2);
		// Dragon Darts activates the absorption effect despite hitting Arcanine twice
		assert.statStage(battle.p2.active[1], 'spe', 1);
	});

	it('should hit one target twice if the other is immunue', () => {
		battle = common.createBattle({ gameType: 'doubles' });
		battle.setPlayer('p1', { team: [
			{ species: "Dragapult", ability: "Clear Body", moves: ["dragondarts"] },
			{ species: "Ludicolo", ability: "Dancer", moves: ["sleeptalk"] },
		] });
		battle.setPlayer('p2', { team: [
			{ species: "Arcanine", ability: "Stamina", moves: ["sleeptalk"] },
			{ species: "Clefairy", ability: "Ripen", moves: ["sleeptalk"] },
		] });
		battle.makeChoices('move dragondarts 2, move sleeptalk', 'move sleeptalk, move sleeptalk');

		assert.statStage(battle.p2.active[0], 'def', 2);
		assert.equal(battle.p2.active[1].hp, battle.p2.active[1].maxhp);
	});

	it('should hit one target twice if the other is semi-invulnerable', () => {
		battle = common.createBattle({ gameType: 'doubles' });
		battle.setPlayer('p1', { team: [
			{ species: "Dragapult", item: "Lagging Tail", ability: "Clear Body", moves: ["dragondarts"] },
			{ species: "Ludicolo", ability: "Dancer", moves: ["sleeptalk"] },
		] });
		battle.setPlayer('p2', { team: [
			{ species: "Arcanine", ability: "Stamina", moves: ["sleeptalk"] },
			{ species: "Golurk", ability: "Ripen", moves: ["phantomforce"] },
		] });
		battle.makeChoices('move dragondarts 2, move sleeptalk', 'move sleeptalk, move phantomforce 1');

		assert.statStage(battle.p2.active[0], 'def', 2);
		assert.equal(battle.p2.active[1].hp, battle.p2.active[1].maxhp);
	});

	it('should hit one target twice if the other is fainted', () => {
		battle = common.createBattle({ gameType: 'doubles' });
		battle.setPlayer('p1', { team: [
			{ species: "Dragapult", ability: "Clear Body", moves: ["dragondarts"] },
			{ species: "Ludicolo", ability: "Dancer", moves: ["sleeptalk"] },
		] });
		battle.setPlayer('p2', { team: [
			{ species: "Arcanine", ability: "Stamina", moves: ["sleeptalk"] },
			{ species: "Snom", ability: "Ripen", moves: ["sleeptalk"] },
		] });

		battle.p2.active[1].faint();
		battle.makeChoices('move dragondarts 2, move sleeptalk', 'move sleeptalk, move sleeptalk');

		assert.statStage(battle.p2.active[0], 'def', 2);
		assert.equal(battle.p2.active[1].hp, 0);
	});

	it('should hit one target twice if the other is Dark type and Dragon Darts is Prankster boosted', () => {
		battle = common.createBattle({ gameType: 'doubles' });
		battle.setPlayer('p1', { team: [
			{ species: "Dragapult", ability: "Clear Body", moves: ["sleeptalk", "dragondarts"] },
			{ species: "Liepard", ability: "Prankster", moves: ["assist"] },
		] });
		battle.setPlayer('p2', { team: [
			{ species: "Arcanine", ability: "Stamina", moves: ["sleeptalk"] },
			{ species: "Spiritomb", ability: "Infiltrator", moves: ["sleeptalk"] },
		] });

		battle.makeChoices();

		assert.statStage(battle.p2.active[0], 'def', 2);
		assert.equal(battle.p2.active[1].hp, battle.p2.active[1].maxhp);
	});

	it('should fail if both targets are fainted', () => {
		battle = common.createBattle({ gameType: 'doubles' });
		battle.setPlayer('p1', { team: [
			{ species: "Dragapult", ability: "Clear Body", moves: ["dragondarts"] },
			{ species: "Ludicolo", ability: "Dancer", moves: ["celebrate"] },
		] });
		battle.setPlayer('p2', { team: [
			{ species: "Arcanine", ability: "Flash Fire", moves: ["celebrate"] },
			{ species: "Arcanine", ability: "Flash Fire", moves: ["celebrate"] },
			{ species: "Arcanine", ability: "Flash Fire", moves: ["celebrate"] },
		] });

		battle.p2.active[0].faint();
		battle.p2.active[1].faint();
		battle.makeChoices('move dragondarts 1, move celebrate', 'move celebrate, move celebrate');

		assert(battle.log.includes(`|-fail|p1a: Dragapult`));
	});
});