File size: 7,880 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
'use strict';

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

describe("Custom Rules", () => {
	it('should support legality tags', () => {
		let team = [
			{ species: 'kitsunoh', ability: 'frisk', moves: ['shadowstrike'], evs: { hp: 1 } },
		];
		assert.false.legalTeam(team, 'gen7anythinggoes');
		assert.legalTeam(team, 'gen7anythinggoes@@@+cap');

		team = [
			{ species: 'pikachu', ability: 'airlock', moves: ['thunderbolt'], evs: { hp: 1 } },
		];
		assert.false.legalTeam(team, 'gen7anythinggoes');
		assert.legalTeam(team, 'gen7ou@@@!obtainableabilities');

		team = [
			{ species: 'pikachu', ability: 'airlock', moves: ['dragondance'], evs: { hp: 1 } },
		];
		assert.false.legalTeam(team, 'gen7ou@@@!obtainableabilities');
	});

	it('should allow Pokemon to be banned', () => {
		let team = [
			{ species: 'pikachu', ability: 'static', moves: ['agility', 'protect', 'thunder', 'thunderbolt'], evs: { hp: 1 } },
		];
		assert.false.legalTeam(team, 'gen7anythinggoes@@@-Pikachu');

		team = [
			{ species: 'greninjaash', ability: 'battlebond', moves: ['surf'], evs: { hp: 1 } },
		];
		assert.false.legalTeam(team, 'gen7anythinggoes@@@-Greninja-Bond');

		team = [
			{ species: 'greninjabond', ability: 'battlebond', moves: ['surf'], evs: { hp: 1 } },
		];
		assert.legalTeam(team, 'gen7anythinggoes@@@!Obtainable Formes,-Greninja-Ash');
	});

	it('should allow Pokemon to be unbanned', () => {
		const team = [
			{ species: 'blaziken', ability: 'blaze', moves: ['skyuppercut'], evs: { hp: 1 } },
		];
		assert.legalTeam(team, 'gen7ou@@@+Blaziken');
	});

	it('should allow Pokemon to be whitelisted', () => {
		let team = [
			{ species: 'giratina', ability: 'pressure', moves: ['protect'], evs: { hp: 1 } },
		];
		assert.legalTeam(team, 'gen7ubers@@@-allpokemon,+giratinaaltered');

		team = [
			{ species: 'giratinaorigin', ability: 'levitate', moves: ['protect'], evs: { hp: 1 } },
		];
		assert.false.legalTeam(team, 'gen7ubers@@@-allpokemon,+giratinaaltered');

		team = [
			{ species: 'tyrantrum', ability: 'strongjaw', moves: ['protect'], evs: { hp: 1 } },
		];
		assert.false.legalTeam(team, 'gen8nationaldex@@@-allpokemon');
	});

	it('should support banning/unbanning tag combinations', () => {
		let team = [
			{ species: 'Crucibelle-Mega', ability: 'Regenerator', moves: ['protect'], evs: { hp: 1 } },
		];
		assert.false.legalTeam(team, 'gen8customgame@@@-nonexistent,+mega',
			"Nonexistent should override all tags that aren't existence-related");

		team = [
			{ species: 'Crucibelle-Mega', ability: 'Regenerator', moves: ['protect'], evs: { hp: 1 } },
		];
		assert.false.legalTeam(team, 'gen8customgame@@@+mega,-nonexistent',
			"Nonexistent should override all tags that aren't existence-related");

		team = [
			{ species: 'Crucibelle-Mega', ability: 'Regenerator', moves: ['protect'], evs: { hp: 1 } },
		];
		assert.legalTeam(team, 'gen8customgame@@@-nonexistent,+crucibellemega',
			"Nonexistent should override all tags that aren't existence-related");

		team = [
			{ species: 'Moltres-Galar', ability: 'Berserk', moves: ['protect'], evs: { hp: 1 } },
		];
		assert.false.legalTeam(team, 'gen8customgame@@@-sublegendary');
	});

	it('should support restrictions', () => {
		let team = [
			{ species: 'Yveltal', ability: 'No Ability', moves: ['protect'], evs: { hp: 1 } },
		];
		assert.legalTeam(team, 'gen7customgame@@@limitonerestricted,*restrictedlegendary');

		team = [
			{ species: 'Yveltal', ability: 'No Ability', moves: ['protect'], evs: { hp: 1 } },
			{ species: 'Xerneas', ability: 'No Ability', moves: ['protect'], evs: { hp: 1 } },
		];
		assert.false.legalTeam(team, 'gen7customgame@@@limitonerestricted,*restrictedlegendary');
	});

	it('should allow moves to be banned', () => {
		const team = [
			{ species: 'pikachu', ability: 'static', moves: ['agility', 'protect', 'thunder', 'thunderbolt'], evs: { hp: 1 } },
		];
		assert.false.legalTeam(team, 'gen7anythinggoes@@@-Agility');
	});

	it('should allow moves to be unbanned', () => {
		const team = [
			{ species: 'absol', ability: 'pressure', moves: ['batonpass'], evs: { hp: 1 } },
		];
		assert.legalTeam(team, 'gen7ou@@@+Baton Pass');
	});

	it('should allow items to be banned', () => {
		let team = [
			{ species: 'pikachu', ability: 'static', moves: ['agility', 'protect', 'thunder', 'thunderbolt'], item: 'lightball', evs: { hp: 1 } },
		];
		assert.false.legalTeam(team, 'gen7anythinggoes@@@-Light Ball');

		team = [
			{ species: 'pikachu', ability: 'static', moves: ['agility', 'protect', 'thunder', 'thunderbolt'], item: 'lightball', evs: { hp: 1 } },
		];
		assert.legalTeam(team, 'gen7anythinggoes@@@-noitem');

		team = [
			{ species: 'pikachu', ability: 'static', moves: ['agility', 'protect', 'thunder', 'thunderbolt'], evs: { hp: 1 } },
		];
		assert.false.legalTeam(team, 'gen7anythinggoes@@@-noitem');

		team = [
			{ species: 'pikachu', ability: 'static', moves: ['agility', 'protect', 'thunder', 'thunderbolt'], evs: { hp: 1 } },
		];
		assert.legalTeam(team, 'gen7anythinggoes@@@-allitems');
	});

	it('should allow items to be unbanned', () => {
		const team = [
			{ species: 'eevee', ability: 'runaway', moves: ['tackle'], item: 'eeviumz', evs: { hp: 1 } },
		];
		assert.legalTeam(team, 'gen7lc@@@+Eevium Z');
	});

	it('should allow abilities to be banned', () => {
		const team = [
			{ species: 'pikachu', ability: 'static', moves: ['agility', 'protect', 'thunder', 'thunderbolt'], evs: { hp: 1 } },
		];
		assert.false.legalTeam(team, 'gen7anythinggoes@@@-Static');
	});

	it('should allow abilities to be unbanned', () => {
		const team = [
			{ species: 'wobbuffet', ability: 'shadowtag', moves: ['counter'], evs: { hp: 1 } },
		];
		assert.legalTeam(team, 'gen7ou@@@+Shadow Tag');
	});

	it('should allow complex bans to be added', () => {
		let team = [
			{ species: 'pikachu', ability: 'static', moves: ['agility', 'protect', 'thunder', 'thunderbolt'], evs: { hp: 1 } },
		];
		assert.false.legalTeam(team, 'gen7anythinggoes@@@-Pikachu + Agility');

		team = [
			{ species: 'smeargle', ability: 'owntempo', moves: ['gravity'], evs: { hp: 1 } },
			{ species: 'pikachu', ability: 'static', moves: ['thunderbolt'], evs: { hp: 1 } },
		];
		assert.false.legalTeam(team, 'gen7doublesou@@@-Gravity ++ Thunderbolt');
	});

	it('should allow complex bans to be altered', () => {
		let team = [
			{ species: 'smeargle', ability: 'owntempo', moves: ['gravity'], evs: { hp: 1 } },
			{ species: 'abomasnow', ability: 'snowwarning', moves: ['grasswhistle'], evs: { hp: 1 } },
		];
		assert.legalTeam(team, 'gen7doublesou@@@-Gravity ++ Grass Whistle > 2');

		team = [
			{ species: 'smeargle', ability: 'owntempo', moves: ['gravity'], evs: { hp: 1 } },
			{ species: 'abomasnow', ability: 'snowwarning', moves: ['grasswhistle'], evs: { hp: 1 } },
			{ species: 'cacturne', ability: 'sandveil', moves: ['grasswhistle'], evs: { hp: 1 } },
		];
		assert.false.legalTeam(team, 'gen7doublesou@@@-Gravity ++ Grass Whistle > 2');
	});

	it('should allow complex bans to be removed', () => {
		const team = [
			{ species: 'smeargle', ability: 'owntempo', moves: ['gravity'], evs: { hp: 1 } },
			{ species: 'abomasnow', ability: 'snowwarning', moves: ['grasswhistle'], evs: { hp: 1 } },
		];
		assert.legalTeam(team, 'gen7doublesou@@@+Gravity ++ Grass Whistle');
	});

	it('should allow rule bundles to be removed', () => {
		const team = [
			{ species: 'azumarill', ability: 'hugepower', moves: ['waterfall'], evs: { hp: 1 } },
			{ species: 'azumarill', ability: 'hugepower', moves: ['waterfall'], evs: { hp: 1 } },
		];
		assert.legalTeam(team, 'gen7ou@@@!Standard');
	});

	it('should allow rule bundles to be overridden', () => {
		const team = [
			{ species: 'charizard-mega-y', ability: 'drought', item: 'charizarditey', moves: ['wingattack'], evs: { hp: 1 } },
		];
		assert.legalTeam(team, 'gen7customgame@@@Standard');
	});
});