File size: 2,590 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
'use strict';

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

let battle;

describe('After You', () => {
	afterEach(() => {
		battle.destroy();
	});

	it(`should cause the targeted Pokemon to immediately move next`, () => {
		battle = common.createBattle({ gameType: 'doubles' }, [[
			{ species: 'Wynaut', ability: 'prankster', moves: ['afteryou'] },
			{ species: 'Magnemite', level: 1, moves: ['magnetrise'] },
		], [
			{ species: 'Great Tusk', moves: ['headlongrush'] },
			{ species: "Magikarp", moves: ['sleeptalk'] },
		]]);

		battle.makeChoices('move afteryou -2, move magnetrise', 'move headlongrush 2, auto');
		const magnemite = battle.p1.active[1];
		assert.false.fainted(magnemite);
	});

	it(`should only cause the target to move next, not run a submove`, () => {
		battle = common.createBattle({ gameType: 'doubles' }, [[
			{ species: 'Wynaut', ability: 'prankster', moves: ['afteryou'] },
			{ species: 'Necrozma', level: 50, ability: 'prankster', moves: ['photongeyser'] },
		], [
			{ species: 'Dugtrio', moves: ['sleeptalk'] },
			{ species: 'Roggenrola', level: 1, ability: 'sturdy', moves: ['sleeptalk'] },
		]]);

		// Photon Geyser has a mechanic where it ignores abilities with Mold Breaker,
		// but doesn't when called via a submove like Sleep Talk. If it fails to KO through Sturdy,
		// it's most likely because it's using submove behavior
		battle.makeChoices('move afteryou -2, move photongeyser 2', 'auto');
		const roggenrola = battle.p2.active[1];
		assert.fainted(roggenrola);
	});

	it(`should work in a free-for-all`, () => {
		battle = common.createBattle({ gameType: 'freeforall' }, [[
			{ species: 'Wynaut', ability: 'prankster', moves: ['afteryou'] },
		], [
			{ species: 'Magnemite', level: 1, moves: ['magnetrise'] },
		], [
			{ species: 'Great Tusk', moves: ['headlongrush'] },
		], [
			{ species: 'Magikarp', moves: ['sleeptalk'] },
		]]);

		battle.makeChoices('move afteryou 1', 'move magnetrise', 'move headlongrush 1', 'auto');
		const magnemite = battle.p2.active[0];
		assert.false.fainted(magnemite);
	});

	it(`should fail in singles whether the user is faster or slower than its target`, () => {
		battle = common.createBattle([[
			{ species: 'Wynaut', moves: ['afteryou', 'ember'] },
		], [
			{ species: 'Tyrogue', moves: ['afteryou', 'seismictoss'] },
		]]);

		battle.makeChoices('move afteryou', 'move seismictoss');
		battle.makeChoices('move ember', 'move afteryou');
		assert(battle.log.includes('|-fail|p1a: Wynaut'));
		assert(battle.log.includes('|-fail|p2a: Tyrogue'));
	});
});