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

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

let battle;

describe('Healing Wish', () => {
	afterEach(() => {
		battle.destroy();
	});

	it('should heal a switch-in for full before hazards at end of turn', () => {
		battle = common.createBattle();
		battle.setPlayer('p1', { team: [
			{ species: 'Caterpie', ability: 'shielddust', moves: ['stringshot'] },
			{ species: 'Jirachi', ability: 'serenegrace', moves: ['healingwish', 'protect'] },
		] });
		battle.setPlayer('p2', { team: [
			{ species: 'Shedinja', ability: 'wonderguard', moves: ['endeavor'] },
			{ species: 'Tyranitar', ability: 'sandstream', moves: ['seismictoss', 'stealthrock'] },
		] });

		battle.makeChoices('move stringshot', 'move endeavor'); // set Caterpie to 1hp
		battle.makeChoices('switch jirachi', 'switch tyranitar'); // set up Sand
		battle.makeChoices('move protect', 'move stealthrock');
		battle.makeChoices('move healingwish', 'move seismictoss');
		assert.equal(battle.requestState, 'switch');
		// sand happens after Jirachi faints and before any switch-in
		battle.makeChoices('switch Caterpie', ''); // Caterpie heals before taking SR damage
		assert.equal(battle.p1.active[0].hp, 174);
		assert.equal(battle.p1.active[0].moveSlots[0].pp, 63);
	});

	it('should not be consumed if a switch-in is fully healed already', () => {
		battle = common.createBattle();
		battle.setPlayer('p1', { team: [
			{ species: 'Jirachi', ability: 'serenegrace', moves: ['healingwish', 'protect'] },
			{ species: 'Caterpie', ability: 'shielddust', moves: ['stringshot'] },
		] });
		battle.setPlayer('p2', { team: [
			{ species: 'Tyranitar', ability: 'sandstream', moves: ['seismictoss', 'stealthrock'] },
		] });
		battle.makeChoices('move protect', 'move stealthrock'); // set up Sand and Stealth Rock
		battle.makeChoices('move healingwish', 'move seismictoss');
		assert.equal(battle.requestState, 'switch');
		// sand happens after Jirachi faints and before any switch-in
		battle.makeChoices('switch Caterpie', ''); // Caterpie does not consume Healing Wish
		assert(battle.p1.slotConditions[0]['healingwish']);
	});

	it('should heal an ally fully after Ally Switch', () => {
		battle = common.createBattle({ gameType: 'doubles' });
		battle.setPlayer('p1', { team: [
			{ species: 'Jirachi', ability: 'serenegrace', moves: ['healingwish'] },
			{ species: 'Caterpie', ability: 'shielddust', moves: ['stringshot'] },
			{ species: 'Rotom', ability: 'levitate', moves: ['allyswitch'] },
		] });
		battle.setPlayer('p2', { team: [
			{ species: 'Garchomp', ability: 'sandveil', moves: ['sleeptalk'] },
			{ species: 'Shedinja', ability: 'wonderguard', moves: ['endeavor', 'protect'] },
		] });
		// set up Healing Wish, Caterpie is at 1 HP
		battle.makeChoices('move healingwish, move stringshot', 'move sleeptalk, move endeavor 2');
		assert.equal(battle.requestState, 'switch');
		// Rotom does not consume Healing Wish
		battle.makeChoices('switch rotom', '');
		assert(battle.p1.slotConditions[0]['healingwish']);
		// Caterpie gets healed by Healing Wish triggered by Ally Switch
		battle.makeChoices('move allyswitch, move stringshot', 'move sleeptalk, move protect');
		assert.equal(battle.p1.active[0].hp, 231); // Caterpie start in slot 1 -> Ally Switch-ed to slot 0
		assert.false(battle.p1.slotConditions[0]['healingwish']);
	});

	it(`should fail to switch the user out if no Pokemon can be switched in`, () => {
		battle = common.createBattle([[
			{ species: 'wynaut', moves: ['healingwish'] },
		], [
			{ species: 'pichu', moves: ['swordsdance'] },
		]]);
		battle.makeChoices();
		assert(battle.log.some(line => line.startsWith('|-fail')));
		assert.false.fainted(battle.p1.active[0]);

		battle = common.createBattle({ gameType: 'doubles' }, [[
			{ species: 'wynaut', moves: ['healingwish'] },
			{ species: 'pichu', moves: ['swordsdance'] },
		], [
			{ species: 'pichu', moves: ['swordsdance'] },
			{ species: 'pichu', moves: ['swordsdance'] },
		]]);
		battle.makeChoices();
		assert(battle.log.some(line => line.startsWith('|-fail')));
		assert.false.fainted(battle.p1.active[0]);
	});

	it(`should not set up the slot condition when it fails`, () => {
		battle = common.createBattle({ gameType: 'doubles' }, [[
			{ species: 'wobbuffet', moves: ['healingwish', 'swordsdance'] },
			{ species: 'wynaut', moves: ['swordsdance', 'allyswitch'] },
		], [
			{ species: 'dratini', moves: ['breakingswipe', 'swordsdance'] },
			{ species: 'pichu', moves: ['swordsdance'] },
		]]);
		const wynaut = battle.p1.active[1];
		battle.makeChoices();
		battle.makeChoices('move swordsdance, move allyswitch', 'move swordsdance, move swordsdance');
		assert(battle.log.some(line => line.startsWith('|-fail')));
		assert.false.fullHP(wynaut);
	});

	it('[Gen 4] should heal a switch-in for full after hazards mid-turn', () => {
		battle = common.gen(4).createBattle();
		battle.setPlayer('p1', { team: [
			{ species: 'Caterpie', ability: 'shielddust', moves: ['stringshot'] },
			{ species: 'Raichu', ability: 'lightningrod', moves: ['growl'] },
			{ species: 'Jirachi', ability: 'serenegrace', moves: ['healingwish'] },
		] });
		battle.setPlayer('p2', { team: [
			{ species: 'Shedinja', ability: 'wonderguard', moves: ['endeavor'] },
			{ species: 'Tyranitar', ability: 'sandstream', moves: ['seismictoss', 'stealthrock'] },
		] });

		battle.makeChoices('move String Shot', 'move Endeavor'); // set Caterpie to 1hp

		battle.makeChoices('switch Raichu', 'switch Tyranitar'); // set up Sand

		battle.makeChoices('move Growl', 'move Stealth Rock');

		battle.makeChoices('switch Jirachi', 'move Seismic Toss');

		battle.makeChoices('move Healing Wish', 'move Seismic Toss');

		battle.makeChoices('switch Caterpie', ''); // Caterpie faints from hazards
		assert.equal(battle.p1.active[0].hp, 0);

		battle.makeChoices('switch Raichu', ''); // Raichu fully heals and takes stoss + Sandstorm damage
		assert.equal(battle.turn, 6);
		assert.equal(battle.p1.active[0].hp, 145); // after stoss + Sandstorm
		assert.equal(battle.p1.active[0].moveSlots[0].pp, 63);
	});
});