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

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

let battle;

describe('Weakness Policy', () => {
	afterEach(() => {
		battle.destroy();
	});

	it('should be triggered by super effective hits', () => {
		battle = common.createBattle();
		battle.setPlayer('p1', { team: [
			{ species: "Lucario", ability: 'justified', moves: ['aurasphere'] },
		] });
		battle.setPlayer('p2', { team: [
			{ species: "Blissey", ability: 'naturalcure', item: 'weaknesspolicy', moves: ['softboiled'] },
		] });
		const holder = battle.p2.active[0];
		battle.makeChoices('move aurasphere', 'move softboiled');
		assert.false.holdsItem(holder);
		assert.statStage(holder, 'atk', 2);
		assert.statStage(holder, 'spa', 2);
	});

	it('should respect individual type effectivenesses in doubles', () => {
		battle = common.createBattle({ gameType: 'doubles' });
		battle.setPlayer('p1', { team: [
			{ species: "Stunfisk", ability: 'limber', moves: ['earthquake', 'surf', 'discharge'] },
			{ species: "Volcarona", ability: 'swarm', item: 'weaknesspolicy', moves: ['roost'] },
		] });
		battle.setPlayer('p2', { team: [
			{ species: "Zekrom", ability: 'teravolt', item: 'weaknesspolicy', moves: ['roost'] },
			{ species: "Pyukumuku", ability: 'unaware', item: 'weaknesspolicy', moves: ['recover'] },
		] });
		const zekrom = battle.p2.active[0];
		const pyuk = battle.p2.active[1];
		const volc = battle.p1.active[1];

		battle.makeChoices('move earthquake, move roost', 'auto');
		assert.false.holdsItem(zekrom);
		assert.statStage(zekrom, 'atk', 2);
		assert.statStage(zekrom, 'spa', 2);
		assert.holdsItem(pyuk);
		assert.statStage(pyuk, 'atk', 0);
		assert.statStage(pyuk, 'spa', 0);
		assert.holdsItem(volc);
		assert.statStage(volc, 'atk', 0);
		assert.statStage(volc, 'spa', 0);

		zekrom.setItem('weaknesspolicy');
		zekrom.clearBoosts();

		battle.makeChoices('move discharge, move roost', 'auto');
		assert.holdsItem(zekrom);
		assert.statStage(zekrom, 'atk', 0);
		assert.statStage(zekrom, 'spa', 0);
		assert.false.holdsItem(pyuk);
		assert.statStage(pyuk, 'atk', 2);
		assert.statStage(pyuk, 'spa', 2);
		assert.holdsItem(volc);
		assert.statStage(volc, 'atk', 0);
		assert.statStage(volc, 'spa', 0);

		pyuk.setItem('weaknesspolicy');
		pyuk.clearBoosts();

		battle.makeChoices('move surf, move roost', 'auto');
		assert.holdsItem(zekrom);
		assert.statStage(zekrom, 'atk', 0);
		assert.statStage(zekrom, 'spa', 0);
		assert.holdsItem(pyuk);
		assert.statStage(pyuk, 'atk', 0);
		assert.statStage(pyuk, 'spa', 0);
		assert.false.holdsItem(volc);
		assert.statStage(volc, 'atk', 2);
		assert.statStage(volc, 'spa', 2);
	});

	it('should not be triggered by fixed damage moves', () => {
		battle = common.createBattle();
		battle.setPlayer('p1', { team: [
			{ species: "Lucario", ability: 'justified', moves: ['seismictoss'] },
		] });
		battle.setPlayer('p2', { team: [
			{ species: "Blissey", ability: 'naturalcure', item: 'weaknesspolicy', moves: ['softboiled'] },
		] });
		const holder = battle.p2.active[0];
		battle.makeChoices('move seismictoss', 'move softboiled');
		assert.holdsItem(holder);
		assert.statStage(holder, 'atk', 0);
		assert.statStage(holder, 'spa', 0);
	});

	it(`should trigger before forced switching moves`, () => {
		battle = common.createBattle([[
			{ species: 'wynaut', ability: 'compoundeyes', moves: ['dragontail'] },
		], [
			{ species: 'zygarde', item: 'weaknesspolicy', moves: ['sleeptalk'] },
			{ species: 'aron', moves: ['sleeptalk'] },
		]]);
		const zygarde = battle.p2.active[0];
		battle.makeChoices();
		assert.false.holdsItem(zygarde);
	});
});