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

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

let battle;

describe('Battle Armor', () => {
	afterEach(() => {
		battle.destroy();
	});

	it('should prevent moves from dealing critical hits', () => {
		battle = common.createBattle([
			[{ species: 'Slowbro', ability: 'battlearmor', moves: ['quickattack'] }],
			[{ species: 'Cryogonal', ability: 'noguard', moves: ['frostbreath'] }],
		]);
		let successfulEvent = false;
		battle.onEvent('ModifyDamage', battle.format, (damage, attacker, defender, move) => {
			if (move.id === 'frostbreath') {
				successfulEvent = true;
				assert(!defender.getMoveHitData(move).crit);
			}
		});
		battle.makeChoices('move quickattack', 'move frostbreath');
		assert(successfulEvent);
	});

	it('should be suppressed by Mold Breaker', () => {
		battle = common.createBattle([
			[{ species: 'Slowbro', ability: 'battlearmor', moves: ['quickattack'] }],
			[{ species: 'Cryogonal', ability: 'moldbreaker', item: 'zoomlens', moves: ['frostbreath'] }],
		]);
		battle.makeChoices('move quickattack', 'move frostbreath');
		let successfulEvent = false;
		battle.onEvent('ModifyDamage', battle.format, (damage, attacker, defender, move) => {
			if (move.id === 'frostbreath') {
				successfulEvent = true;
				assert(defender.getMoveHitData(move).crit);
			}
		});
		battle.makeChoices('move quickattack', 'move frostbreath');
		assert(successfulEvent);
	});
});