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

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

let battle;

describe('Magic Room', () => {
	afterEach(() => {
		battle.destroy();
	});

	it(`should negate residual healing events`, () => {
		battle = common.createBattle([[
			{ species: 'Lopunny', item: 'leftovers', moves: ['bellydrum'] },
		], [
			{ species: 'Golem', moves: ['magicroom'] },
		]]);
		const lopunny = battle.p1.active[0];
		battle.makeChoices();
		assert.equal(lopunny.hp, Math.ceil(lopunny.maxhp / 2));
	});

	it(`should prevent items from being consumed`, () => {
		battle = common.createBattle([[
			{ species: 'Lopunny', item: 'chopleberry', moves: ['magicroom'] },
		], [
			{ species: 'Golem', moves: ['lowkick'] },
		]]);
		battle.makeChoices();
		assert.holdsItem(battle.p1.active[0]);
	});

	it(`should ignore the effects of items that disable moves`, () => {
		battle = common.createBattle([[
			{ species: 'Lopunny', item: 'assaultvest', moves: ['protect'] },
		], [
			{ species: 'Golem', moves: ['magicroom'] },
		]]);
		const lopunny = battle.p1.active[0];
		battle.makeChoices();
		assert.equal(lopunny.lastMove.id, 'struggle');
		battle.makeChoices();
		assert.equal(lopunny.lastMove.id, 'protect');
	});

	it(`should cause Fling to fail`, () => {
		battle = common.createBattle([[
			{ species: 'Lopunny', item: 'seaincense', moves: ['fling'] },
		], [
			{ species: 'Deoxys-Speed', moves: ['magicroom'] },
		]]);
		battle.makeChoices();
		assert.holdsItem(battle.p1.active[0]);
	});

	it(`should not prevent Mega Evolution`, () => {
		battle = common.createBattle([[
			{ species: 'Lopunny', item: 'lopunnite', moves: ['sleeptalk'] },
		], [
			{ species: 'Deoxys-Speed', moves: ['magicroom'] },
		]]);
		battle.makeChoices('move sleeptalk mega', 'move magicroom');
		assert.species(battle.p1.active[0], 'Lopunny-Mega');
	});

	it(`should not prevent Primal Reversion`, () => {
		battle = common.createBattle([[
			{ species: 'Zapdos', moves: ['uturn'] },
			{ species: 'Groudon', ability: 'drought', item: 'redorb', moves: ['protect'] },
		], [
			{ species: 'Accelgor', moves: ['magicroom'] },
		]]);
		battle.makeChoices();
		battle.makeChoices('switch 2');
		assert.species(battle.p1.active[0], 'Groudon-Primal');
	});
});