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

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

let battle;

describe('Desolate Land', () => {
	afterEach(() => {
		battle.destroy();
	});

	it('should activate the Desolate Land weather upon switch-in', () => {
		battle = common.createBattle([[
			{ species: "Groudon", ability: 'desolateland', moves: ['helpinghand'] },
		], [
			{ species: "Abra", ability: 'magicguard', moves: ['teleport'] },
		]]);
		assert(battle.field.isWeather('desolateland'));
	});

	it('should increase the damage (not the basePower) of Fire-type attacks', () => {
		battle = common.createBattle([[
			{ species: 'Ninetales', ability: 'desolateland', moves: ['incinerate'] },
		], [
			{ species: 'Cryogonal', ability: 'levitate', moves: ['splash'] },
		]]);
		battle.randomizer = dmg => dmg; // max damage
		const attacker = battle.p1.active[0];
		const defender = battle.p2.active[0];
		assert.hurtsBy(defender, 152, () => battle.makeChoices('move incinerate', 'move splash'));
		const move = Dex.moves.get('incinerate');
		const basePower = battle.runEvent('BasePower', attacker, defender, move, move.basePower, true);
		assert.equal(basePower, move.basePower);
	});

	it('should cause Water-type attacks to fail', () => {
		battle = common.createBattle([[
			{ species: "Groudon", ability: 'desolateland', moves: ['helpinghand'] },
		], [
			{ species: "Blastoise", ability: 'torrent', moves: ['surf'] },
		]]);
		battle.makeChoices('move helpinghand', 'move surf');
		assert.fullHP(battle.p1.active[0]);
	});

	it('should not cause Water-type Status moves to fail', () => {
		battle = common.createBattle([[
			{ species: "Groudon", ability: 'desolateland', moves: ['helpinghand'] },
		], [
			{ species: "Blastoise", ability: 'torrent', moves: ['soak'] },
		]]);
		const soakTarget = battle.p1.active[0];
		assert.sets(() => soakTarget.getTypes().join('/'), 'Water', () => battle.makeChoices('move helpinghand', 'move soak'));
	});

	it('should prevent moves and abilities from setting the weather to Sunny Day, Rain Dance, Sandstorm, or Hail', () => {
		battle = common.createBattle([[
			{ species: "Groudon", ability: 'desolateland', moves: ['helpinghand'] },
		], [
			{ species: "Abra", ability: 'magicguard', moves: ['teleport'] },
			{ species: "Kyogre", ability: 'drizzle', moves: ['raindance'] },
			{ species: "Groudon", ability: 'drought', moves: ['sunnyday'] },
			{ species: "Tyranitar", ability: 'sandstream', moves: ['sandstorm'] },
			{ species: "Abomasnow", ability: 'snowwarning', moves: ['hail'] },
		]]);
		for (let i = 2; i <= 5; i++) {
			battle.makeChoices('move helpinghand', 'switch ' + i);
			assert(battle.field.isWeather('desolateland'));
			battle.makeChoices('move helpinghand', 'move 1');
			assert(battle.field.isWeather('desolateland'));
		}
	});

	it('should be treated as Sunny Day for any forme, move or ability that requires it', () => {
		battle = common.createBattle([[
			{ species: "Groudon", ability: 'desolateland', moves: ['helpinghand', 'solarbeam'] },
		], [
			{ species: "Castform", ability: 'forecast', moves: ['weatherball'] },
			{ species: "Cherrim", ability: 'flowergift', moves: ['growth'] },
			{ species: "Charizard", ability: 'solarpower', moves: ['roost'] },
			{ species: "Venusaur", ability: 'chlorophyll', moves: ['growth'] },
			{ species: "Toxicroak", ability: 'dryskin', moves: ['bulkup'] },
		]]);
		battle.onEvent('Hit', battle.format, (target, pokemon, move) => {
			if (move.id === 'weatherball') {
				assert.equal(move.type, 'Fire');
			}
		});
		const myActive = battle.p2.active;
		battle.makeChoices('move helpinghand', 'move weatherball');
		assert.species(myActive[0], 'Castform-Sunny');
		battle.makeChoices('move helpinghand', 'switch 2');
		assert.species(myActive[0], 'Cherrim-Sunshine');
		battle.makeChoices('move helpinghand', 'switch 3');
		assert.false.fullHP(myActive[0], "Charizard should be hurt by Solar Power");
		battle.makeChoices('move solarbeam', 'switch 4');
		assert.equal(myActive[0].getStat('spe'), 2 * myActive[0].storedStats['spe'], "Venusaur's speed should be doubled by Chlorophyll");
		assert.false.fullHP(myActive[0], "Solar Beam should skip its charge turn");
		battle.makeChoices('move helpinghand', 'switch 5');
		assert.false.fullHP(myActive[0], "Toxicroak should be hurt by Dry Skin");
	});

	it('should cause the Desolate Land weather to fade if it switches out and no other Desolate Land Pokemon are active', () => {
		battle = common.createBattle([[
			{ species: "Groudon", ability: 'desolateland', moves: ['helpinghand'] },
			{ species: "Ho-Oh", ability: 'pressure', moves: ['roost'] },
		], [
			{ species: "Lugia", ability: 'pressure', moves: ['roost'] },
		]]);
		assert.sets(() => battle.field.isWeather('desolateland'), false, () => battle.makeChoices('switch 2', 'move roost'));
	});

	it('should not cause the Desolate Land weather to fade if it switches out and another Desolate Land Pokemon is active', () => {
		battle = common.createBattle([[
			{ species: "Groudon", ability: 'desolateland', moves: ['helpinghand'] },
			{ species: "Ho-Oh", ability: 'pressure', moves: ['roost'] },
		], [
			{ species: "Groudon", ability: 'desolateland', moves: ['bulkup'] },
		]]);
		assert.constant(() => battle.field.isWeather('desolateland'), () => battle.makeChoices('switch 2', 'move bulkup'));
	});

	it('should cause the Desolate Land weather to fade if its ability is suppressed and no other Desolate Land Pokemon are active', () => {
		battle = common.createBattle([[
			{ species: "Groudon", ability: 'desolateland', moves: ['helpinghand'] },
		], [
			{ species: "Lugia", ability: 'pressure', moves: ['gastroacid'] },
		]]);
		assert.sets(() => battle.field.isWeather('desolateland'), false, () => battle.makeChoices('move helpinghand', 'move gastroacid'));
	});

	it('should not cause the Desolate Land weather to fade if its ability is suppressed and another Desolate Land Pokemon is active', () => {
		battle = common.createBattle([[
			{ species: "Groudon", ability: 'desolateland', moves: ['helpinghand'] },
		], [
			{ species: "Groudon", ability: 'desolateland', moves: ['gastroacid'] },
		]]);
		assert.constant(() => battle.field.isWeather('desolateland'), () => battle.makeChoices('move helpinghand', 'move gastroacid'));
	});

	it('should cause the Desolate Land weather to fade if its ability is changed and no other Desolate Land Pokemon are active', () => {
		battle = common.createBattle([[
			{ species: "Groudon", ability: 'desolateland', moves: ['helpinghand'] },
		], [
			{ species: "Lugia", ability: 'pressure', moves: ['entrainment'] },
		]]);
		assert.sets(() => battle.field.isWeather('desolateland'), false, () => battle.makeChoices('move helpinghand', 'move entrainment'));
	});

	it('should fade after being forced out via Roar', () => {
		battle = common.createBattle([[
			{ species: 'Groudon', item: "Red Orb", moves: ['sleeptalk'] },
			{ species: 'Wynaut', moves: ['sleeptalk'] },
		], [
			{ species: 'Wynaut', moves: ['roar'] },
		]]);
		battle.makeChoices();
		assert.false(battle.field.isWeather('desolateland'));
	});

	it(`should cause Water-type Natural Gift to fail`, () => {
		battle = common.createBattle([[
			{ species: 'Groudon', item: 'Red Orb', moves: ['sleeptalk'] },
		], [
			{ species: 'Wynaut', moves: ['naturalgift'] },
		]]);
		battle.makeChoices();
		assert.fullHP(battle.p1.active[0]);
	});
});