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

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

let battle;

describe('Metronome (item)', () => {
	afterEach(() => {
		battle.destroy();
	});

	it(`should increase the damage of moves that have been used successfully and consecutively`, () => {
		battle = common.createBattle([[
			{ species: 'wynaut', item: 'metronome', moves: ['psystrike'] },
		], [
			{ species: 'cleffa', evs: { hp: 252 }, ability: 'shellarmor', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		const cleffa = battle.p2.active[0];
		const hpAfterOneAttack = cleffa.hp;
		battle.makeChoices();
		const damage = hpAfterOneAttack - cleffa.hp;
		assert.bounded(damage, [115, 137]);
	});

	it(`should reset the multiplier after switching moves`, () => {
		battle = common.createBattle([[
			{ species: 'wynaut', item: 'metronome', moves: ['psystrike', 'sleeptalk'] },
		], [
			{ species: 'cleffa', evs: { hp: 252 }, ability: 'shellarmor', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		const cleffa = battle.p2.active[0];
		const hpAfterOneAttack = cleffa.hp;
		battle.makeChoices('move sleeptalk', 'auto');
		battle.makeChoices();
		const damage = hpAfterOneAttack - cleffa.hp;
		assert.bounded(damage, [96, 114]);
	});

	it(`should reset the multiplier after hitting Protect`, () => {
		battle = common.createBattle([[
			{ species: 'wynaut', item: 'metronome', moves: ['psystrike'] },
		], [
			{ species: 'cleffa', evs: { hp: 252 }, ability: 'shellarmor', moves: ['sleeptalk', 'protect'] },
		]]);
		battle.makeChoices();
		const cleffa = battle.p2.active[0];
		const hpAfterOneAttack = cleffa.hp;
		battle.makeChoices('auto', 'move protect');
		battle.makeChoices();
		const damage = hpAfterOneAttack - cleffa.hp;
		assert.bounded(damage, [96, 114]);
	});

	it(`should instantly start moves that use a charging turn at Metronome 1 boost level, then increase linearly`, () => {
		battle = common.createBattle([[
			{ species: 'dusknoir', item: 'metronome', moves: ['dig'] },
		], [
			{ species: 'blissey', ability: 'shellarmor', moves: ['softboiled'] },
		]]);
		battle.makeChoices();
		battle.makeChoices();
		const blissey = battle.p2.active[0];
		let damage = blissey.maxhp - blissey.hp;

		// Metronome 1 and 2 damage rolls always overlap in range, so we can't use assert.bounded here.
		let possibleDamageRolls = [290, 294, 296, 300, 304, 307, 311, 314, 318, 320, 324, 328, 331, 335, 338, 342];
		const damageWasMetronome1Boosted = possibleDamageRolls.includes(damage);
		assert(damageWasMetronome1Boosted, `Dig should be Metronome 1 boosted`);

		battle.makeChoices();
		battle.makeChoices();
		damage = blissey.maxhp - blissey.hp;
		possibleDamageRolls = [339, 343, 346, 350, 354, 358, 363, 367, 371, 374, 378, 382, 386, 391, 395, 399];
		const damageWasMetronome2Boosted = possibleDamageRolls.includes(damage);
		assert(damageWasMetronome2Boosted, `Dig should be Metronome 2 boosted`);
	});

	it(`should not instantly start moves that skip a charging turn at Metronome 1 boost level`, () => {
		battle = common.createBattle([[
			{ species: 'slowbro', item: 'metronome', moves: ['solarbeam'] },
		], [
			{ species: 'blissey', ability: 'shellarmor', moves: ['sunnyday'] },
			{ species: 'blissey', ability: 'cloudnine', moves: ['luckychant'] },
		]]);
		battle.makeChoices();
		const blissey = battle.p2.active[0];
		let damage = blissey.maxhp - blissey.hp;
		assert.bounded(damage, [67, 79], `Solar Beam should not be Metronome boosted`);

		battle.makeChoices('auto', 'switch 2');
		battle.makeChoices();
		const newBlissey = battle.p2.active[0];
		damage = newBlissey.maxhp - newBlissey.hp;
		assert.bounded(damage, [80, 95], `Solar Beam should be Metronome 1 boosted`);
	});

	it(`should use called moves to determine the Metronome multiplier`, () => {
		battle = common.createBattle([[
			{ species: 'goomy', item: 'metronome', moves: ['copycat', 'surf'] },
		], [
			{ species: 'clefable', evs: { hp: 252 }, ability: 'shellarmor', moves: ['softboiled', 'surf'] },
		]]);
		battle.makeChoices('move copycat', 'move surf');
		const clefable = battle.p2.active[0];
		let damage = clefable.maxhp - clefable.hp;
		assert.bounded(damage, [45, 53], `Surf should not be Metronome boosted`);

		const hpAfterOneAttack = clefable.hp;
		battle.makeChoices('move copycat', 'move surf');
		damage = hpAfterOneAttack - clefable.hp;
		assert.bounded(damage, [54, 64], `Surf should be Metronome 1 boosted`);

		battle.makeChoices('move surf', 'move softboiled');
		damage = clefable.maxhp - clefable.hp;
		assert.bounded(damage, [63, 74], `Surf should be Metronome 2 boosted`);
	});
});