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

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

let battle;

describe(`Eject Pack`, () => {
	afterEach(() => {
		battle.destroy();
	});

	it(`should switch out the holder when its stats are lowered`, () => {
		battle = common.createBattle([[
			{ species: 'Magikarp', item: 'ejectpack', moves: ['splash'] },
			{ species: 'Mew', moves: ['splash'] },
		], [
			{ species: 'Machop', moves: ['leer'] },
		]]);
		battle.makeChoices();
		assert.equal(battle.p1.requestState, 'switch');
	});

	it(`should switch out the holder after Moody's stat drop`, () => {
		battle = common.createBattle([[
			{ species: 'Glalie', ability: 'moody', item: 'ejectpack', moves: ['protect'] },
			{ species: 'Mew', moves: ['protect'] },
		], [
			{ species: 'Mew', moves: ['protect'] },
		]]);
		battle.makeChoices();
		assert.equal(battle.p1.requestState, 'switch');
	});

	it(`should not switch the holder out if the move was Parting Shot and the opponent could switch`, () => {
		battle = common.createBattle([[
			{ species: 'Wynaut', item: 'ejectpack', moves: ['sleeptalk'] },
			{ species: 'Mew', moves: ['sleeptalk'] },
		], [
			{ species: 'Mew', moves: ['partingshot'] },
			{ species: 'Muk', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		assert.false.equal(battle.p1.requestState, 'switch');
		assert.equal(battle.p2.requestState, 'switch');
	});

	it(`should switch out the holder if its stats are lowered during the semi-invulnerable state`, () => {
		battle = common.createBattle([[
			{ species: 'Charmeleon', item: 'ejectpack', moves: ['phantomforce'] },
			{ species: 'Wynaut', moves: ['sleeptalk'] },
		], [
			{ species: 'Wynaut', ability: 'noguard', moves: ['growl'] },
		]]);
		battle.makeChoices();
		assert.equal(battle.p1.requestState, 'switch');
	});

	it(`should switch out the holder if its stats are lowered after using Swallow`, () => {
		battle = common.createBattle([[
			{ species: 'Charmeleon', item: 'ejectpack', moves: ['stockpile', 'swallow'] },
			{ species: 'Wynaut', moves: ['sleeptalk'] },
		], [
			{ species: 'Wynaut', moves: ['tackle'] },
		]]);
		battle.makeChoices();
		battle.makeChoices('move swallow', 'auto');
		assert.equal(battle.p1.requestState, 'switch');
	});

	it(`should not switch out the user if the user acquired the Eject Pack after the stat drop occurred`, () => {
		battle = common.createBattle([[
			{ species: 'Klefki', ability: 'magician', moves: ['lowsweep'] },
			{ species: 'Wynaut', moves: ['sleeptalk'] },
		], [
			{ species: 'Grimmsnarl', ability: 'pickpocket', item: 'cheriberry', moves: ['sleeptalk'] },
			{ species: 'Wynaut', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		assert.false.equal(battle.requestState, 'switch');
	});

	it.skip(`should wait until after all other end-turn effects have resolved before switching out the holder`, () => {
		battle = common.createBattle([[
			{ species: 'Glalie', item: 'ejectpack', ability: 'moody', moves: ['icebeam'] },
			{ species: 'Wynaut', moves: ['sleeptalk'] },
		], [
			{ species: 'Zygarde', item: 'focussash', ability: 'powerconstruct', moves: ['octolock'] },
		]]);
		battle.makeChoices();
		const log = battle.getDebugLog();
		const moodyIndex = log.lastIndexOf('|-ability|p1a: Glalie|Moody|boost');
		const powerConstructIndex = log.lastIndexOf('|-activate|p2a: Zygarde|ability: Power Construct');
		const ejectPackIndex = log.lastIndexOf('|-enditem|p1a: Glalie|Eject Pack');
		assert(moodyIndex < ejectPackIndex, 'Eject Pack should not activate before Moody');
		assert(powerConstructIndex < ejectPackIndex, 'Eject Pack should not activate before Power Construct');
	});

	it.skip(`should not activate when another switching effect was triggered as part of the move`, () => {
		battle = common.createBattle({ gameType: 'doubles' }, [[
			{ species: 'Hydreigon', moves: ['breakingswipe'] },
			{ species: 'Horsea', moves: ['sleeptalk'] },
		], [
			{ species: 'Zeraora', item: 'ejectpack', moves: ['sleeptalk'] },
			{ species: 'Mew', item: 'ejectbutton', moves: ['sleeptalk'] },
			{ species: 'Wynaut', moves: ['sleeptalk'] },
			{ species: 'Wynaut', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		battle.makeChoices();
		assert.species(battle.p2.active[0], 'Zeraora', `Zeraora should not have switched out with its Eject Pack.`);
		assert.species(battle.p2.active[1], 'Wynaut', `Mew should have switched out with its Eject Button.`);
	});

	it.skip(`should only trigger the fastest Eject Pack when multiple targets with Eject Pack have stats lowered`, () => {
		battle = common.createBattle({ gameType: 'doubles' }, [[
			{ species: 'Hydreigon', moves: ['leer'] },
			{ species: 'Horsea', moves: ['sleeptalk'] },
		], [
			{ species: 'Morelull', item: 'ejectpack', moves: ['sleeptalk'] },
			{ species: 'Mew', item: 'ejectpack', moves: ['sleeptalk'] },
			{ species: 'Wynaut', moves: ['sleeptalk'] },
			{ species: 'Wynaut', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		battle.makeChoices();
		assert.species(battle.p2.active[0], 'Morelull');
		assert.species(battle.p2.active[1], 'Wynaut');
	});

	it(`should not prevent entrance Abilities from resolving during simultaneous switches`, () => {
		battle = common.createBattle({ gameType: 'doubles' }, [[
			{ species: 'Hydreigon', ability: 'intimidate', moves: ['sleeptalk'] },
			{ species: 'Wynaut', moves: ['sleeptalk'] },
		], [
			{ species: 'Morelull', ability: 'drought', item: 'ejectpack', moves: ['sleeptalk'] },
			{ species: 'Mew', level: 1, ability: 'electricsurge', moves: ['sleeptalk'] },
			{ species: 'Wynaut', moves: ['sleeptalk'] },
		]]);
		assert(battle.field.isWeather('sunnyday'));
		assert(battle.field.isTerrain('electricterrain'));
		assert.equal(battle.p2.requestState, 'switch');
	});

	it.skip(`should not prohibit switchins if a switch has already resolved to a slot replaced by Eject Pack`, () => {
		battle = common.createBattle({ gameType: 'doubles' }, [[
			{ species: 'Pheromosa', moves: ['sleeptalk'] },
			{ species: 'Wynaut', moves: ['sleeptalk'] },
			{ species: 'Incineroar', ability: 'intimidate', moves: ['sleeptalk'] },
		], [
			{ species: 'Morelull', item: 'ejectpack', moves: ['sleeptalk'] },
			{ species: 'Mew', moves: ['sleeptalk'] },
			{ species: 'Wynaut', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices('switch 3, move sleeptalk', 'move sleeptalk, switch 3');
		battle.makeChoices();
		assert.species(battle.p2.active[0], 'Wynaut');
		assert.species(battle.p2.active[0], 'Morelull');
	});
});