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

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

let battle;

describe('Inverse Battle', () => {
	afterEach(() => {
		battle.destroy();
	});

	it(`should change natural resistances into weaknesses`, () => {
		battle = common.createBattle({ inverseMod: true }, [[
			{ species: 'wynaut', moves: ['vitalthrow'] },
		], [
			{ species: 'scyther', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		assert(battle.log[battle.lastMoveLine + 1].startsWith('|-supereffective|'));
	});

	it(`should change natural weaknesses into resistances`, () => {
		battle = common.createBattle({ inverseMod: true }, [[
			{ species: 'wynaut', moves: ['vitalthrow'] },
		], [
			{ species: 'absol', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		assert(battle.log[battle.lastMoveLine + 1].startsWith('|-resisted|'));
	});

	it(`should negate natural immunities and make them weaknesses`, () => {
		battle = common.createBattle({ inverseMod: true }, [[
			{ species: 'wynaut', moves: ['vitalthrow'] },
		], [
			{ species: 'dusknoir', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		assert(battle.log[battle.lastMoveLine + 1].startsWith('|-supereffective|'));
		assert.false.fullHP(battle.p2.active[0]);
	});

	it(`should affect Stealth Rock damage`, () => {
		battle = common.createBattle({ inverseMod: true }, [[
			{ species: 'wynaut', moves: ['stealthrock', 'snore'] },
		], [
			{ species: 'ninjask', moves: ['sleeptalk'] },
			{ species: 'steelix', moves: ['sleeptalk'] },
			{ species: 'hitmonchan', moves: ['sleeptalk'] },
			{ species: 'chansey', moves: ['sleeptalk'] },
			{ species: 'staraptor', moves: ['sleeptalk'] },
			{ species: 'volcarona', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		let pokemon;
		let expectedDamage;
		for (let i = 2; i <= 6; i++) {
			battle.makeChoices('move snore', 'switch ' + i);
			pokemon = battle.p2.active[0];
			expectedDamage = Math.floor(pokemon.maxhp * 0.5 ** (i - 1));
			assert.equal(pokemon.maxhp - pokemon.hp, expectedDamage, `${pokemon.name} should take ${expectedDamage} damage`);
		}
	});

	it(`should affect the resistance of Delta Stream`, () => {
		battle = common.createBattle({ inverseMod: true }, [[
			{ species: 'wynaut', moves: ['hiddenpowerbug'] },
		], [
			{ species: 'rayquazamega', ability: 'deltastream', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		assert(!battle.log[battle.lastMoveLine + 1].startsWith('|-supereffective|'));
	});

	it(`should make Ghost/Grass types take neutral damage from Flying Press`, () => {
		battle = common.createBattle({ inverseMod: true }, [[
			{ species: 'hawlucha', moves: ['flyingpress'] },
		], [
			{ species: 'gourgeist', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		assert(!battle.log[battle.lastMoveLine + 1].startsWith('|-supereffective|'));
	});

	it(`should not affect ability-based immunities`, () => {
		battle = common.createBattle({ inverseMod: true }, [[
			{ species: 'wynaut', moves: ['earthquake'] },
		], [
			{ species: 'mismagius', ability: 'levitate', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		assert(battle.log[battle.lastMoveLine + 1].startsWith('|-immune|'));
		assert.fullHP(battle.p2.active[0]);
	});

	it(`should not affect move-based immunities`, () => {
		battle = common.createBattle({ inverseMod: true }, [[
			{ species: 'wynaut', moves: ['earthquake'] },
		], [
			{ species: 'klefki', moves: ['magnetrise'] },
		]]);
		battle.makeChoices();
		assert(battle.log[battle.lastMoveLine + 1].startsWith('|-immune|'));
		assert.fullHP(battle.p2.active[0]);
	});

	it(`should not affect the type effectiveness of Freeze Dry on Water-type Pokemon`, () => {
		battle = common.createBattle({ inverseMod: true }, [[
			{ species: 'wynaut', moves: ['freezedry'] },
		], [
			{ species: 'floatzel', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		assert(battle.log[battle.lastMoveLine + 1].startsWith('|-supereffective|'));
	});

	it(`should not affect the "ungrounded" state of Flying-type Pokemon`, () => {
		battle = common.createBattle({ inverseMod: true }, [[
			{ species: 'wynaut', moves: ['spore'] },
		], [
			{ species: 'talonflame', moves: ['mistyterrain'] },
		]]);
		battle.makeChoices();
		assert.equal(battle.p2.active[0].status, 'slp');
	});

	it(`should let Tera Shell take not very effective damage`, () => {
		battle = common.createBattle({ inverseMod: true }, [[
			{ species: 'wynaut', moves: ['wickedblow'] },
		], [
			{ species: 'Terapagos-Terastal', ability: 'terashell', moves: ['sleeptalk'] },
		]]);
		battle.makeChoices();
		const terapagos = battle.p2.active[0];
		const damage = terapagos.maxhp - terapagos.hp;
		assert.bounded(damage, [14, 16], `Tera Shell should yield not very effective damage roll, actual damage taken is ${damage}`);

		battle.makeChoices();
		assert.bounded(terapagos.maxhp - terapagos.hp - damage, [28, 33], `Tera Shell should not reduce damage, because Terapagos-Terastal was not at full HP`);
	});
});