Spaces:
Running
Running
File size: 11,522 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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
'use strict';
const assert = require('./../../assert');
const common = require('./../../common');
let battle;
const trappers = ['Block', 'Mean Look', 'Spider Web', 'Thousand Waves', 'Anchor Shot', 'Spirit Shackle'];
const partialtrappers = ['Bind', 'Clamp', 'Fire Spin', 'Infestation', 'Magma Storm', 'Sand Tomb', 'Whirlpool', 'Wrap'];
describe('Trapping Moves', () => {
afterEach(() => {
battle.destroy();
});
for (const move of trappers) {
it('should prevent Pokemon from switching out normally', () => {
battle = common.createBattle();
battle.setPlayer('p1', { team: [{ species: "Smeargle", ability: 'prankster', moves: [toID(move)] }] });
battle.setPlayer('p2', { team: [
{ species: "Tangrowth", ability: 'leafguard', moves: ['swordsdance'] },
{ species: "Starmie", ability: 'illuminate', moves: ['reflecttype'] },
] });
battle.makeChoices('move ' + toID(move), 'move swordsdance');
assert.trapped(() => battle.makeChoices('move ' + toID(move), 'switch 2'));
assert.equal(battle.p2.active[0].species.id, 'tangrowth');
});
it('should not prevent Pokemon from switching out using moves', () => {
battle = common.createBattle();
battle.setPlayer('p1', { team: [{ species: "Smeargle", ability: 'prankster', moves: [toID(move)] }] });
battle.setPlayer('p2', { team: [
{ species: "Tangrowth", ability: 'leafguard', moves: ['batonpass'] },
{ species: "Starmie", ability: 'illuminate', moves: ['reflecttype'] },
] });
battle.makeChoices('move ' + toID(move), 'move batonpass');
battle.makeChoices('', 'switch 2');
assert.equal(battle.p2.active[0].species.id, 'starmie');
});
it('should not prevent Pokemon immune to trapping from switching out', () => {
battle = common.createBattle();
battle.setPlayer('p1', { team: [{ species: "Smeargle", ability: 'prankster', moves: [toID(move)] }] });
battle.setPlayer('p2', { team: [
{ species: "Gourgeist", ability: 'insomnia', moves: ['synthesis'] },
{ species: "Starmie", ability: 'illuminate', moves: ['reflecttype'] },
] });
battle.makeChoices('move ' + toID(move), 'move synthesis');
battle.makeChoices('move ' + toID(move), 'switch 2');
assert.equal(battle.p2.active[0].species.id, 'starmie');
});
it('should stop trapping the Pokemon if the user is no longer active', () => {
battle = common.createBattle();
battle.setPlayer('p1', { team: [
{ species: "Smeargle", ability: 'prankster', moves: [toID(move)] },
{ species: "Kyurem", ability: 'pressure', moves: ['rest'] },
] });
battle.setPlayer('p2', { team: [
{ species: "Tangrowth", ability: 'leafguard', moves: ['roar'] },
{ species: "Starmie", ability: 'illuminate', moves: ['reflecttype'] },
] });
battle.makeChoices('move ' + toID(move), 'move roar');
battle.makeChoices('move rest', 'switch 2');
assert.equal(battle.p2.active[0].species.id, 'starmie');
});
it('should free all trapped Pokemon if the user is no longer active', () => {
battle = common.createBattle({ gameType: 'doubles' });
battle.setPlayer('p1', { team: [
{ species: "Smeargle", ability: 'prankster', moves: [toID(move)] },
{ species: "Cobalion", ability: 'justified', item: 'laggingtail', moves: ['swordsdance', 'closecombat'] },
] });
battle.setPlayer('p2', { team: [
{ species: "Tangrowth", ability: 'leafguard', moves: ['synthesis'] },
{ species: "Starmie", ability: 'illuminate', moves: ['recover'] },
{ species: "Cradily", ability: 'suctioncups', moves: ['recover'] },
{ species: "Hippowdon", ability: 'sandstream', moves: ['slackoff'] },
] });
if (move !== 'Thousand Waves') {
battle.makeChoices('move ' + toID(move) + ' 1, move swordsdance', 'move synthesis, move recover');
battle.makeChoices('move ' + toID(move) + ' 2, move closecombat -1', 'move synthesis, move recover');
} else {
battle.makeChoices('move ' + toID(move) + ', move closecombat -1', 'move synthesis, move recover');
}
battle.makeChoices('move swordsdance', 'switch 3, switch 4');
assert.equal(battle.p2.active[0].species.id, 'cradily');
assert.equal(battle.p2.active[1].species.id, 'hippowdon');
});
if (trappers.indexOf(move) < 3) {
// Only test on moves that existed in gen 4
it('should be passed when the user uses Baton Pass in Gen 4', () => {
battle = common.gen(4).createBattle();
battle.setPlayer('p1', { team: [
{ species: "Smeargle", ability: 'prankster', moves: [toID(move), 'batonpass'] },
{ species: "Shedinja", ability: 'wonderguard', moves: ['rest'] },
] });
battle.setPlayer('p2', { team: [
{ species: "Tangrowth", ability: 'leafguard', moves: ['synthesis', 'roar'] },
{ species: "Starmie", ability: 'illuminate', moves: ['reflecttype'] },
] });
battle.makeChoices('move ' + toID(move), 'move synthesis');
battle.makeChoices('move batonpass', 'move synthesis');
battle.makeChoices('switch 2', '');
assert.equal(battle.p2.active[0].species.id, 'tangrowth');
battle.makeChoices('move rest', 'move roar');
battle.makeChoices('move batonpass', 'switch 2');
assert.equal(battle.p2.active[0].species.id, 'starmie');
});
}
}
});
describe('Partial Trapping Moves', () => {
afterEach(() => {
battle.destroy();
});
for (const move of partialtrappers) {
it('should deal 1/8 HP per turn', () => {
battle = common.createBattle();
battle.setPlayer('p1', { team: [{ species: "Smeargle", ability: 'noguard', moves: [toID(move), 'rest'] }] });
battle.setPlayer('p2', { team: [{ species: "Blissey", ability: 'naturalcure', moves: ['healbell'] }] });
battle.makeChoices('move ' + toID(move), 'move healbell');
const pokemon = battle.p2.active[0];
pokemon.heal(pokemon.maxhp);
battle.makeChoices('move rest', 'move healbell');
assert.equal(pokemon.maxhp - pokemon.hp, battle.modify(pokemon.maxhp, 1 / 8));
});
it('should prevent Pokemon from switching out normally', () => {
battle = common.createBattle();
battle.setPlayer('p1', { team: [{ species: "Smeargle", ability: 'noguard', moves: [toID(move)] }] });
battle.setPlayer('p2', { team: [
{ species: "Blissey", ability: 'naturalcure', moves: ['healbell'] },
{ species: "Starmie", ability: 'illuminate', moves: ['reflecttype'] },
] });
battle.makeChoices('move ' + toID(move), 'move healbell');
assert.trapped(() => battle.makeChoices('move ' + toID(move), 'switch 2'));
assert.equal(battle.p2.active[0].species.id, 'blissey');
});
it('should not prevent Pokemon from switching out using moves', () => {
battle = common.createBattle();
battle.setPlayer('p1', { team: [{ species: "Smeargle", ability: 'noguard', moves: [toID(move)] }] });
battle.setPlayer('p2', { team: [
{ species: "Blissey", ability: 'naturalcure', moves: ['batonpass'] },
{ species: "Starmie", ability: 'illuminate', moves: ['reflecttype'] },
] });
battle.makeChoices('move ' + toID(move), 'move batonpass');
battle.makeChoices('', 'switch 2');
assert.equal(battle.p2.active[0].species.id, 'starmie');
});
it('should not prevent Pokemon immune to trapping from switching out', () => {
battle = common.createBattle();
battle.setPlayer('p1', { team: [{ species: "Smeargle", ability: 'noguard', moves: [toID(move)] }] });
battle.setPlayer('p2', { team: [
{ species: "Dusknoir", ability: 'frisk', moves: ['sleeptalk'] },
{ species: "Starmie", ability: 'illuminate', moves: ['reflecttype'] },
] });
battle.makeChoices('move ' + toID(move), 'move sleeptalk');
battle.makeChoices('move ' + toID(move), 'switch 2');
assert.equal(battle.p2.active[0].species.id, 'starmie');
});
it('should stop trapping the Pokemon if the user is no longer active', () => {
battle = common.createBattle();
battle.setPlayer('p1', { team: [
{ species: "Smeargle", ability: 'noguard', moves: [toID(move)] },
{ species: "Kyurem", ability: 'pressure', moves: ['rest'] },
] });
battle.setPlayer('p2', { team: [
{ species: "Blissey", ability: 'naturalcure', moves: ['roar'] },
{ species: "Starmie", ability: 'illuminate', moves: ['reflecttype'] },
] });
battle.makeChoices('move ' + toID(move), 'move roar');
battle.makeChoices('move rest', 'switch 2');
assert.equal(battle.p2.active[0].species.id, 'starmie');
});
it('should stop trapping the Pokemon if the target uses Rapid Spin', () => {
battle = common.createBattle();
battle.setPlayer('p1', { team: [
{ species: "Smeargle", ability: 'noguard', moves: [toID(move)] },
{ species: "Kyurem", ability: 'pressure', moves: ['rest'] },
] });
battle.setPlayer('p2', { team: [
{ species: "Blissey", ability: 'naturalcure', moves: ['rapidspin'] },
{ species: "Starmie", ability: 'illuminate', moves: ['reflecttype'] },
] });
battle.makeChoices('move ' + toID(move), 'move rapidspin');
battle.makeChoices('move ' + toID(move), 'switch 2');
assert.equal(battle.p2.active[0].species.id, 'starmie');
});
}
});
describe('Partial Trapping Moves [Gen 1]', () => {
afterEach(() => {
battle.destroy();
});
it('Wrap ends when wrapped Pokemon dies of residual damage', () => {
battle = common.gen(1).createBattle();
battle.setPlayer('p1', { team: [{ species: "Arbok", moves: ['wrap', 'toxic'] }] });
battle.setPlayer('p2', { team: [{ species: "Rhydon", moves: ['splash'] }, { species: "Exeggutor", moves: ['splash'] }] });
battle.makeChoices('move toxic', 'move splash');
for (let i = 0; i < 6; i++) {
battle.makeChoices();
}
assert(!battle.p1.active[0].volatiles['partialtrappinglock']);
});
it('Wrap ends when wrapped Pokemon switches to a Pokemon that dies of residual damage', () => {
battle = common.gen(1).createBattle();
battle.setPlayer('p1', { team: [{ species: "Dragonite", moves: ['wrap', 'seismictoss', 'toxic'], evs: { hp: 255 } }] });
battle.setPlayer('p2', { team: [{ species: "Mewtwo", moves: ['splash'], evs: { hp: 255 } }, { species: "Exeggutor", moves: ['splash'] }] });
for (let i = 0; i < 4; i++) {
battle.makeChoices('move seismictoss', 'auto');
}
battle.makeChoices('move toxic', 'auto');
battle.makeChoices('move wrap', 'switch 2');
battle.makeChoices('move wrap', 'switch 2');
battle.makeChoices();
assert(!battle.p1.active[0].volatiles['partialtrappinglock']);
});
it('Wrap ends when wrapper dies to residual damage', () => {
battle = common.gen(1).createBattle();
battle.setPlayer('p1', { team: [{ species: "Dragonite", moves: ['wrap', 'splash'] }, { species: "Exeggutor", moves: ['splash'] }] });
battle.setPlayer('p2', { team: [{ species: "Rhydon", moves: ['toxic'] }] });
battle.makeChoices('move splash', 'move toxic');
for (let i = 0; i < 7; i++) {
battle.makeChoices();
}
assert(!battle.p2.active[0].volatiles['partiallytrapped']);
});
it('Wrap ends when wrapper switches to a Pokemon that dies of residual damage', () => {
battle = common.gen(1).createBattle();
battle.setPlayer('p1', { team: [{ species: "Rhydon", moves: ['splash'], evs: { hp: 255 } }, { species: "Dragonite", moves: ['wrap'] }] });
battle.setPlayer('p2', { team: [{ species: "Slowbro", moves: ['seismictoss', 'toxic'] }] });
for (let i = 0; i < 4; i++) {
battle.makeChoices();
}
battle.makeChoices('move splash', 'move toxic');
battle.makeChoices('switch 2', 'auto');
battle.makeChoices();
battle.makeChoices('switch 2', 'auto');
battle.makeChoices();
assert(!battle.p2.active[0].volatiles['partiallytrapped']);
});
});
|