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

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

let battle;

describe('Magnet Pull', () => {
	afterEach(() => {
		battle.destroy();
	});

	it('should prevent Steel-type Pokemon from switching out normally', () => {
		battle = common.createBattle();
		battle.setPlayer('p1', { team: [{ species: "Magnezone", ability: 'magnetpull', moves: ['soak', 'charge'] }] });
		battle.setPlayer('p2', { team: [
			{ species: "Heatran", ability: 'flashfire', moves: ['curse'] },
			{ species: "Starmie", ability: 'illuminate', moves: ['reflecttype'] },
		] });

		assert.trapped(() => battle.makeChoices('', 'switch 2'), true);
		battle.makeChoices('auto', 'auto');
		assert.species(battle.p2.active[0], 'Heatran');
		battle.makeChoices('auto', 'switch 2');
		assert.species(battle.p2.active[0], 'Starmie');
		battle.makeChoices('move charge', 'move reflecttype'); // Reflect Type makes Starmie part Steel
		assert.trapped(() => battle.makeChoices('', 'switch 2'), true);
		battle.makeChoices('auto', 'auto');
		assert.species(battle.p2.active[0], 'Starmie');
	});

	it('should not prevent Steel-type Pokemon from switching out using moves', () => {
		battle = common.createBattle();
		battle.setPlayer('p1', { team: [{ species: "Magnezone", ability: 'magnetpull', moves: ['toxic'] }] });
		battle.setPlayer('p2', { team: [
			{ species: "Heatran", ability: 'flashfire', moves: ['batonpass'] },
			{ species: "Tentacruel", ability: 'clearbody', moves: ['rapidspin'] },
		] });
		battle.makeChoices('move toxic', 'move batonpass');
		battle.makeChoices('', 'switch 2');
		assert.species(battle.p2.active[0], 'Tentacruel');
	});

	it('should not prevent Pokemon immune to trapping from switching out', () => {
		battle = common.createBattle();
		battle.setPlayer('p1', { team: [{ species: "Magnezone", ability: 'magnetpull', moves: ['substitute'] }] });
		battle.setPlayer('p2', { team: [
			{ species: "Aegislash", ability: 'stancechange', moves: ['swordsdance'] },
			{ species: "Arcanine", ability: 'flashfire', moves: ['roar'] },
		] });
		battle.makeChoices('move substitute', 'switch 2');
		assert.species(battle.p2.active[0], 'Arcanine');
	});
});