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

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

let battle;

// tests are derived from the following post and related quotes:
// https://www.smogon.com/forums/threads/scarlet-violet-battle-mechanics-research.3709545/post-9417627
describe('Ceaseless Edge', () => {
	afterEach(() => {
		battle.destroy();
	});

	it(`should set up Spikes on the side of the opponent`, () => {
		battle = common.createBattle([[
			{ species: 'samurotthisui', ability: 'noguard', moves: ['ceaselessedge'] },
		], [
			{ species: 'registeel', moves: ['splash'] },
		]]);

		battle.makeChoices();
		assert.equal(battle.p2.sideConditions.spikes?.layers, 1);
	});

	it(`should set up Spikes on the side of the opponent, not necessarily the target, in a double battle`, () => {
		battle = common.createBattle({ gameType: 'doubles' }, [[
			{ species: 'samurotthisui', ability: 'noguard', moves: ['ceaselessedge'] },
			{ species: 'pikachu', moves: ['splash'] },
		], [
			{ species: 'squirtle', moves: ['splash'] },
			{ species: 'bulbasaur', moves: ['splash'] },
		]]);

		battle.makeChoices('move ceaselessedge -2, move splash', 'move splash, move splash');

		assert.equal(!!(battle.p1.sideConditions.spikes), false);
		assert.equal(battle.p2.sideConditions.spikes?.layers, 1);
	});

	it(`should still set up Spikes on the side of the opponent that is behind a Substitute`, () => {
		battle = common.createBattle([[
			{ species: 'samurotthisui', ability: 'noguard', moves: ['ceaselessedge'] },
		], [
			{ species: 'regieleki', moves: ['substitute'] },
		]]);

		battle.makeChoices();
		assert.equal(battle.p2.sideConditions.spikes?.layers, 1);
	});

	it(`should not set up Spikes if the move does not hit opponent or its Substitute`, () => {
		battle = common.createBattle([[
			{ species: 'samurotthisui', ability: 'noguard', moves: ['ceaselessedge'] },
		], [
			{ species: 'regieleki', moves: ['protect'] },
		]]);

		battle.makeChoices();
		assert.equal(!!(battle.p2.sideConditions.spikes), false);
	});

	it(`should not be bounced back by Magic Bounce`, () => {
		battle = common.createBattle([[
			{ species: 'samurotthisui', ability: 'noguard', moves: ['ceaselessedge'] },
		], [
			{ species: 'registeel', ability: 'magicbounce', moves: ['splash'] },
		]]);

		battle.makeChoices();
		assert.equal(!!(battle.p1.sideConditions.spikes), false);
		assert.equal(battle.p2.sideConditions.spikes?.layers, 1);
	});

	it(`should have its Spikes prevented by Sheer Force`, () => {
		battle = common.createBattle([[
			{ species: 'samurotthisui', ability: 'sheerforce', moves: ['ceaselessedge'] },
		], [
			{ species: 'registeel', ability: 'noguard', moves: ['splash'] },
		]]);

		battle.makeChoices();
		assert.equal(!!(battle.p2.sideConditions.spikes), false);
	});

	it(`should not set Spikes when the user faints from Rocky Helmet`, () => {
		battle = common.createBattle([[
			{ species: 'samurotthisui', ability: 'noguard', item: 'focussash', moves: ['ceaselessedge'] },
			{ species: 'wynaut', moves: ['sleeptalk'] },
		], [
			{ species: 'regieleki', item: 'rockyhelmet', moves: ['sheercold'] },
		]]);

		battle.makeChoices(); // Samurott will faint to the Rocky Helmet
		assert.equal(!!(battle.p2.sideConditions.spikes), false);
	});
});