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

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

let battle;

describe("Accuracy", () => {
	afterEach(() => {
		battle.destroy();
	});

	it(`should round half down when applying a modifier`, () => {
		battle = common.createBattle([
			[{ species: 'Butterfree', ability: 'compoundeyes', moves: ['sleeppowder'] }],
			[{ species: 'Beldum', moves: ['poltergeist'] }],
		]);

		battle.onEvent('Accuracy', battle.format, accuracy => {
			assert.equal(accuracy, 98, 'CompoundEyes Sleep Powder should be 98% accurate');
		});

		battle.makeChoices();

		battle = common.createBattle([
			[{ species: 'Butterfree', ability: 'victorystar', moves: ['fireblast'] }],
			[{ species: 'Regirock', moves: ['sleeptalk'] }],
		]);

		battle.onEvent('Accuracy', battle.format, accuracy => {
			assert.equal(accuracy, 94, 'Victory Star Fire Blast should be 94% accurate');
		});

		battle.makeChoices();

		battle = common.createBattle([
			[{ species: 'Butterfree', item: 'widelens', moves: ['fireblast'] }],
			[{ species: 'Regirock', moves: ['sleeptalk'] }],
		]);

		battle.onEvent('Accuracy', battle.format, accuracy => {
			assert.equal(accuracy, 93, 'Wide Lens Fire Blast should be 93% accurate');
		});

		battle.makeChoices();
	});

	it(`should chain modifiers in order of the Pokemon's raw speed`, () => {
		battle = common.createBattle({ gameType: 'doubles' }, [[
			{ species: 'Mewtwo', ability: 'victorystar', moves: ['gravity', 'sleeptalk', 'sandattack'] },
			{ species: 'Charizard', ability: 'compoundeyes', moves: ['sleeptalk', 'fireblast'] },
		], [
			{ species: 'Bonsly', ability: 'tangledfeet', moves: ['doubleteam', 'sleeptalk'] },
			{ species: 'Pyukumuku', ability: 'noguard', moves: ['confuseray', 'sandattack', 'sleeptalk'] },
		]]);

		battle.makeChoices('move sandattack -2, move sleeptalk', 'move doubleteam, move sandattack 2');
		battle.makeChoices('auto', 'move sleeptalk, move confuseray -1');

		battle.onEvent('Accuracy', battle.format, (accuracy, target, source, move) => {
			if (move.id !== 'fireblast') return;
			assert.equal(accuracy, 51);
		});

		battle.makeChoices('move gravity, move fire blast 1', 'move sleeptalk, move sleeptalk');

		// Changing the Pokemon's Speeds around changes the chaining order, which affects the result
		battle = common.createBattle({ gameType: 'doubles' }, [[
			{ species: 'Bonsly', ability: 'victorystar', moves: ['gravity', 'sleeptalk', 'sandattack'] },
			{ species: 'Charizard', ability: 'compoundeyes', moves: ['sleeptalk', 'fireblast'] },
		], [
			{ species: 'Mewtwo', ability: 'tangledfeet', moves: ['doubleteam', 'sleeptalk'] },
			{ species: 'Pyukumuku', ability: 'noguard', moves: ['confuseray', 'sandattack', 'sleeptalk'] },
		]]);

		battle.makeChoices('move sandattack -2, move sleeptalk', 'move doubleteam, move sandattack 2');
		battle.makeChoices('auto', 'move sleeptalk, move confuseray -1');

		battle.onEvent('Accuracy', battle.format, (accuracy, target, source, move) => {
			if (move.id !== 'fireblast') return;
			assert.equal(accuracy, 50);
		});

		battle.makeChoices('move gravity, move fire blast 1', 'move sleeptalk, move sleeptalk');
	});
});