Spaces:
Running
Running
File size: 7,777 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 |
'use strict';
const assert = require('./../../assert');
const common = require('./../../common');
let battle;
describe('Endless Battle Clause (slow)', () => {
afterEach(() => battle.destroy());
it('should trigger on an infinite loop', () => {
battle = common.createBattle({ endlessBattleClause: true });
battle.setPlayer('p1', { team: [{ species: "Caterpie", moves: ['tackle'] }] });
battle.setPlayer('p2', { team: [{ species: "Slowbro", item: 'leppaberry', moves: ['slackoff', 'healpulse', 'recycle'] }] });
const [victim, memeSlowbro] = [battle.p1.active[0], battle.p2.active[0]];
skipTurns(battle, 100);
for (let i = 0; i < 100; i++) {
if (battle.ended) {
assert.equal(battle.winner, 'Player 1');
return;
}
let move;
if (victim.hp < 150) {
move = 'healpulse';
} else if (memeSlowbro.item === '') {
move = 'recycle';
} else {
move = 'slackoff';
}
battle.makeChoices('default', `move ${move}`);
}
assert.fail("The battle did not end despite Endless Battle Clause");
});
it('should not trigger by both Pokemon eating a Leppa Berry they started with', () => {
battle = common.createBattle({ endlessBattleClause: true });
battle.setPlayer('p1', { team: [{ species: "Sunkern", item: 'leppaberry', moves: ['synthesis'] }] });
battle.setPlayer('p2', { team: [{ species: "Sunkern", item: 'leppaberry', moves: ['synthesis'] }] });
skipTurns(battle, 100);
for (let i = 0; i < 10; i++) {
battle.makeChoices('move synthesis', 'move synthesis');
}
assert.false(battle.ended);
});
it('should only cause the battle to end if either side cannot switch to a non-stale Pokemon and at least one staleness is externally inflicted', () => {
battle = common.createBattle({ endlessBattleClause: true });
battle.setPlayer('p1', { team: [
{ species: "Blissey", level: 1, item: 'leppaberry', moves: ['recycle', 'extremespeed', 'floralhealing', 'block'] },
{ species: "Magikarp", moves: ['splash'] },
] });
battle.setPlayer('p2', { team: [
{ species: "Magikarp", moves: ['splash'] },
{ species: "Sunkern", item: 'leppaberry', moves: ['synthesis'] },
] });
skipTurns(battle, 100);
for (let i = 0; i < 8; i++) {
battle.makeChoices('move extremespeed', 'move splash');
}
// Blissey consumes a Leppa Berry that wasn't cycled = no staleness.
assert.false(battle.ended);
battle.makeChoices('move recycle', 'move splash');
assert.false(battle.ended);
for (let i = 0; i < 8; i++) {
battle.makeChoices('move extremespeed', 'move splash');
}
// Blissey consumes a Leppa Berry which was cycled = internal staleness.
assert.false(battle.ended);
// Blissey inflicts external staleness on Magikarp.
battle.makeChoices('move floralhealing', 'move splash');
// Magikarp can still be switched out to Sunkern at this point, so EBC still shouldn't trigger
assert.false(battle.ended);
battle.makeChoices('move block', 'move splash');
// Now that Magikarp is trapped, the termination condition should occur.
assert(battle.ended);
assert.equal(battle.winner, 'Player 2');
});
it('Fling should cause externally inflicted staleness', () => {
battle = common.createBattle({ endlessBattleClause: true });
battle.setPlayer('p1', { team: [
{ species: "Blissey", level: 1, item: 'leppaberry', moves: ['recycle', 'extremespeed', 'fling', 'block'] },
{ species: "Magikarp", moves: ['splash'] },
] });
battle.setPlayer('p2', { team: [
{ species: "Magikarp", moves: ['splash'] },
{ species: "Sunkern", item: 'leppaberry', moves: ['synthesis'] },
] });
skipTurns(battle, 100);
// Blissey inflicts external staleness on Magikarp.
battle.makeChoices('move fling', 'move splash');
assert.false(battle.ended);
battle.makeChoices('move recycle', 'move splash');
for (let i = 0; i < 8; i++) {
battle.makeChoices('move extremespeed', 'move splash');
}
assert.false(battle.ended);
battle.makeChoices('move block', 'move splash');
// Now that Magikarp is trapped, the termination condition should occur.
assert(battle.ended);
assert.equal(battle.winner, 'Player 2');
});
it('Entrainment should cause externally inflicted staleness', () => {
battle = common.createBattle({ endlessBattleClause: true });
battle.setPlayer('p1', { team: [
{ species: "Blissey", ability: 'Levitate', level: 1, item: 'leppaberry', moves: ['recycle', 'extremespeed', 'entrainment', 'block'] },
{ species: "Magikarp", moves: ['splash'] },
] });
battle.setPlayer('p2', { team: [
{ species: "Magikarp", ability: 'Illuminate', moves: ['splash'] },
{ species: "Sunkern", item: 'leppaberry', moves: ['synthesis'] },
] });
skipTurns(battle, 100);
// Blissey inflicts external staleness on Magikarp.
battle.makeChoices('move entrainment', 'move splash');
assert.false(battle.ended);
for (let i = 0; i < 8; i++) {
battle.makeChoices('move extremespeed', 'move splash');
}
assert.false(battle.ended);
battle.makeChoices('move recycle', 'move splash');
assert.false(battle.ended);
for (let i = 0; i < 8; i++) {
battle.makeChoices('move extremespeed', 'move splash');
}
assert.false(battle.ended);
battle.makeChoices('move block', 'move splash');
// Now that Magikarp is trapped, the termination condition should occur.
assert(battle.ended);
assert.equal(battle.winner, 'Player 2');
});
it('Entrainment\'s externally inflicted staleness should go away on switch', () => {
battle = common.createBattle({ endlessBattleClause: true });
battle.setPlayer('p1', { team: [
{ species: "Blissey", ability: 'Levitate', level: 1, item: 'leppaberry', moves: ['recycle', 'extremespeed', 'entrainment', 'block'] },
{ species: "Magikarp", moves: ['splash'] },
] });
battle.setPlayer('p2', { team: [
{ species: "Magikarp", ability: 'Illuminate', moves: ['splash'] },
{ species: "Sunkern", item: 'leppaberry', moves: ['synthesis'] },
] });
skipTurns(battle, 100);
// Blissey inflicts external staleness on Magikarp.
battle.makeChoices('move entrainment', 'move splash');
assert.false(battle.ended);
for (let i = 0; i < 8; i++) {
battle.makeChoices('move extremespeed', 'move splash');
}
assert.false(battle.ended);
battle.makeChoices('move recycle', 'move splash');
assert.false(battle.ended);
for (let i = 0; i < 8; i++) {
battle.makeChoices('move extremespeed', 'move splash');
}
assert.false(battle.ended);
battle.makeChoices('move recycle', 'switch 2');
battle.makeChoices('move block', 'switch 2');
assert(!battle.ended);
});
it('should allow for a maximum of 1000 turns', function () {
this.timeout(0);
battle = common.createBattle({ endlessBattleClause: true });
battle.setPlayer('p1', { team: [
{ species: "Gengar", moves: ['splash'] },
{ species: "Clefable", moves: ['splash'] },
] });
battle.setPlayer('p2', { team: [
{ species: "Blissey", moves: ['splash'] },
{ species: "Vaporeon", moves: ['splash'] },
] });
for (let i = 0; i < 998; i++) {
battle.makeChoices('switch 2', 'switch 2');
}
assert(!battle.ended);
battle.makeChoices('switch 2', 'switch 2');
assert(battle.ended);
});
it('Skill Swap should remove the user\'s staleness', () => {
battle = common.createBattle({ endlessBattleClause: true }, [[
{ species: "Furret", moves: ['skillswap'] },
], [
{ species: "Ampharos", moves: ['skillswap'] },
]]);
skipTurns(battle, 100);
for (let i = 0; i < 8; i++) battle.makeChoices();
assert.false(battle.ended);
});
});
// Endless Battle Clause doesn't take effect for 100 turns, so we artificially skip turns
// to get the turn counter to be in the range which could possibly trigger the clause
function skipTurns(battle, turns) {
for (let i = 0; i < turns; i++) battle.endTurn();
}
|