mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-12-18 15:55:20 +01:00
604 lines
26 KiB
TypeScript
604 lines
26 KiB
TypeScript
import { BattlerIndex } from "#app/battle";
|
|
import { RandomMoveAttr } from "#app/data/moves/move";
|
|
import type Pokemon from "#app/field/pokemon";
|
|
import { MoveResult } from "#app/field/pokemon";
|
|
import type { MovePhase } from "#app/phases/move-phase";
|
|
import { Abilities } from "#enums/abilities";
|
|
import { MoveUseType } from "#enums/move-use-type";
|
|
import { Moves } from "#enums/moves";
|
|
import { Species } from "#enums/species";
|
|
import GameManager from "#test/testUtils/gameManager";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
describe("Moves - Instruct", () => {
|
|
let phaserGame: Phaser.Game;
|
|
let game: GameManager;
|
|
|
|
function instructSuccess(target: Pokemon, move: Moves): void {
|
|
expect(target.getLastXMoves(-1)[0].move).toBe(move);
|
|
expect(target.getLastXMoves(-1)[1].move).toBe(target.getLastXMoves()[0].move);
|
|
expect(target.getMoveset().find(m => m?.moveId === move)?.ppUsed).toBe(2);
|
|
}
|
|
|
|
beforeAll(() => {
|
|
phaserGame = new Phaser.Game({
|
|
type: Phaser.HEADLESS,
|
|
});
|
|
});
|
|
|
|
afterEach(() => {
|
|
game.phaseInterceptor.restoreOg();
|
|
});
|
|
|
|
beforeEach(() => {
|
|
game = new GameManager(phaserGame);
|
|
game.override
|
|
.battleStyle("single")
|
|
.enemySpecies(Species.SHUCKLE)
|
|
.enemyAbility(Abilities.NO_GUARD)
|
|
.enemyLevel(100)
|
|
.startingLevel(100)
|
|
.disableCrits();
|
|
});
|
|
|
|
it("should repeat target's last used move", async () => {
|
|
game.override.moveset(Moves.INSTRUCT).enemyLevel(1000); // ensures shuckle no die
|
|
await game.classicMode.startBattle([Species.AMOONGUSS]);
|
|
|
|
const enemy = game.scene.getEnemyPokemon()!;
|
|
game.move.changeMoveset(enemy, Moves.SONIC_BOOM);
|
|
|
|
game.move.select(Moves.INSTRUCT);
|
|
await game.move.selectEnemyMove(Moves.SONIC_BOOM);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
|
|
await game.phaseInterceptor.to("MovePhase"); // enemy attacks us
|
|
await game.phaseInterceptor.to("MovePhase", false); // instruct
|
|
let currentPhase = game.scene.getCurrentPhase() as MovePhase;
|
|
expect(currentPhase.pokemon).toBe(game.scene.getPlayerPokemon());
|
|
await game.phaseInterceptor.to("MoveEndPhase");
|
|
|
|
await game.phaseInterceptor.to("MovePhase", false); // enemy repeats move
|
|
currentPhase = game.scene.getCurrentPhase() as MovePhase;
|
|
expect(currentPhase.pokemon).toBe(enemy);
|
|
expect(currentPhase.move.moveId).toBe(Moves.SONIC_BOOM);
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
instructSuccess(enemy, Moves.SONIC_BOOM);
|
|
expect(game.scene.getPlayerPokemon()?.getInverseHp()).toBe(40);
|
|
});
|
|
|
|
it("should repeat enemy's move through substitute", async () => {
|
|
game.override.moveset([Moves.INSTRUCT, Moves.SPLASH]);
|
|
await game.classicMode.startBattle([Species.AMOONGUSS]);
|
|
|
|
const enemy = game.scene.getEnemyPokemon()!;
|
|
game.move.changeMoveset(enemy, [Moves.SONIC_BOOM, Moves.SUBSTITUTE]);
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
await game.move.selectEnemyMove(Moves.SUBSTITUTE);
|
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
await game.toNextTurn();
|
|
|
|
game.move.select(Moves.INSTRUCT);
|
|
await game.move.selectEnemyMove(Moves.SONIC_BOOM);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
instructSuccess(game.scene.getEnemyPokemon()!, Moves.SONIC_BOOM);
|
|
expect(game.scene.getPlayerPokemon()?.getInverseHp()).toBe(40);
|
|
});
|
|
|
|
it("should repeat ally's attack on enemy", async () => {
|
|
game.override.battleStyle("double").enemyMoveset(Moves.SPLASH);
|
|
await game.classicMode.startBattle([Species.AMOONGUSS, Species.SHUCKLE]);
|
|
|
|
const [amoonguss, shuckle] = game.scene.getPlayerField();
|
|
game.move.changeMoveset(amoonguss, [Moves.INSTRUCT, Moves.SONIC_BOOM]);
|
|
game.move.changeMoveset(shuckle, [Moves.INSTRUCT, Moves.SONIC_BOOM]);
|
|
|
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2);
|
|
game.move.select(Moves.SONIC_BOOM, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
|
|
await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]);
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
instructSuccess(shuckle, Moves.SONIC_BOOM);
|
|
expect(game.scene.getEnemyField()[0].getInverseHp()).toBe(40);
|
|
});
|
|
|
|
// TODO: Enable test case once gigaton hammer (and blood moon) are reworked
|
|
it.todo("should repeat enemy's Gigaton Hammer", async () => {
|
|
game.override.moveset(Moves.INSTRUCT).enemyLevel(5);
|
|
await game.classicMode.startBattle([Species.AMOONGUSS]);
|
|
|
|
const enemy = game.scene.getEnemyPokemon()!;
|
|
game.move.changeMoveset(enemy, [Moves.GIGATON_HAMMER, Moves.BLOOD_MOON]);
|
|
|
|
game.move.select(Moves.INSTRUCT);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
instructSuccess(enemy, Moves.GIGATON_HAMMER);
|
|
expect(game.scene.getPlayerPokemon()!.turnData.attacksReceived.length).toBe(2);
|
|
});
|
|
|
|
it("should add moves to move queue for copycat", async () => {
|
|
game.override.battleStyle("double").moveset(Moves.INSTRUCT).enemyLevel(5);
|
|
await game.classicMode.startBattle([Species.AMOONGUSS]);
|
|
|
|
const [enemy1, enemy2] = game.scene.getEnemyField()!;
|
|
game.move.changeMoveset(enemy1, Moves.WATER_GUN);
|
|
game.move.changeMoveset(enemy2, Moves.COPYCAT);
|
|
|
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2]);
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
instructSuccess(enemy1, Moves.WATER_GUN);
|
|
// amoonguss gets hit by water gun thrice; once by original attack, once by instructed use and once by copycat
|
|
expect(game.scene.getPlayerPokemon()!.turnData.attacksReceived.length).toBe(3);
|
|
});
|
|
|
|
it("should fail on metronomed moves, even if also in moveset", async () => {
|
|
vi.spyOn(RandomMoveAttr.prototype, "getMoveOverride").mockReturnValue(Moves.ABSORB);
|
|
await game.classicMode.startBattle([Species.AMOONGUSS]);
|
|
|
|
const enemy = game.scene.getEnemyPokemon()!;
|
|
game.move.changeMoveset(enemy, [Moves.METRONOME, Moves.ABSORB]);
|
|
|
|
game.move.use(Moves.INSTRUCT);
|
|
await game.move.selectEnemyMove(Moves.METRONOME);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
expect(game.scene.getPlayerPokemon()!.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
|
});
|
|
|
|
it("should respect enemy's status condition", async () => {
|
|
game.override.moveset([Moves.INSTRUCT, Moves.THUNDER_WAVE]).enemyMoveset(Moves.SONIC_BOOM);
|
|
await game.classicMode.startBattle([Species.AMOONGUSS]);
|
|
|
|
game.move.select(Moves.THUNDER_WAVE);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
await game.toNextTurn();
|
|
|
|
game.move.select(Moves.INSTRUCT);
|
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
await game.phaseInterceptor.to("MovePhase");
|
|
// force enemy's instructed move (and only the instructed move) to bork
|
|
await game.move.forceStatusActivation(true);
|
|
await game.move.forceStatusActivation(false);
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
const moveHistory = game.scene.getEnemyPokemon()?.getLastXMoves(-1)!;
|
|
expect(moveHistory.map(m => m.move)).toEqual([Moves.SONIC_BOOM, Moves.NONE, Moves.SONIC_BOOM]);
|
|
expect(game.scene.getPlayerPokemon()?.getInverseHp()).toBe(40);
|
|
});
|
|
|
|
it("should not repeat enemy's out of pp move", async () => {
|
|
game.override.moveset(Moves.INSTRUCT).enemySpecies(Species.UNOWN);
|
|
await game.classicMode.startBattle([Species.AMOONGUSS]);
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
game.move.changeMoveset(enemyPokemon, Moves.HIDDEN_POWER);
|
|
const moveUsed = enemyPokemon.moveset.find(m => m?.moveId === Moves.HIDDEN_POWER)!;
|
|
moveUsed.ppUsed = moveUsed.getMovePp() - 1;
|
|
|
|
game.move.select(Moves.INSTRUCT);
|
|
await game.move.selectEnemyMove(Moves.HIDDEN_POWER);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
const playerMoves = game.field.getPlayerPokemon().getLastXMoves(-1);
|
|
expect(playerMoves[0].result).toBe(MoveResult.FAIL);
|
|
expect(enemyPokemon.getMoveHistory().length).toBe(1);
|
|
});
|
|
|
|
it("should redirect attacking moves if enemy faints", async () => {
|
|
game.override.battleStyle("double").enemyMoveset(Moves.SPLASH).enemySpecies(Species.MAGIKARP).enemyLevel(1);
|
|
await game.classicMode.startBattle([Species.HISUI_ELECTRODE, Species.KOMMO_O]);
|
|
|
|
const [electrode, kommo_o] = game.scene.getPlayerField()!;
|
|
game.move.changeMoveset(electrode, Moves.CHLOROBLAST);
|
|
game.move.changeMoveset(kommo_o, Moves.INSTRUCT);
|
|
|
|
game.move.select(Moves.CHLOROBLAST, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER);
|
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]);
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
// Chloroblast always deals 50% max HP% recoil UNLESS you whiff
|
|
// due to lack of targets or similar,
|
|
// so all we have to do is check whether electrode fainted or not.
|
|
// Naturally, both karps should also be dead as well.
|
|
expect(electrode.isFainted()).toBe(true);
|
|
const [karp1, karp2] = game.scene.getEnemyField()!;
|
|
expect(karp1.isFainted()).toBe(true);
|
|
expect(karp2.isFainted()).toBe(true);
|
|
});
|
|
|
|
it("should allow for dancer copying of instructed dance move", async () => {
|
|
game.override.battleStyle("double").enemyMoveset([Moves.INSTRUCT, Moves.SPLASH]).enemyLevel(1000);
|
|
await game.classicMode.startBattle([Species.ORICORIO, Species.VOLCARONA]);
|
|
|
|
const [oricorio, volcarona] = game.scene.getPlayerField();
|
|
game.move.changeMoveset(oricorio, Moves.SPLASH);
|
|
game.move.changeMoveset(volcarona, Moves.FIERY_DANCE);
|
|
|
|
game.move.select(Moves.SPLASH, BattlerIndex.PLAYER);
|
|
game.move.select(Moves.FIERY_DANCE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
|
|
await game.move.selectEnemyMove(Moves.INSTRUCT, BattlerIndex.PLAYER_2);
|
|
await game.move.selectEnemyMove(Moves.SPLASH);
|
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]);
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
// fiery dance triggered dancer successfully for a total of 4 hits
|
|
// Enemy level is set to a high value so that it does not faint even after all 4 hits
|
|
instructSuccess(volcarona, Moves.FIERY_DANCE);
|
|
expect(game.scene.getEnemyField()[0].turnData.attacksReceived.length).toBe(4);
|
|
});
|
|
|
|
it("should not repeat move when switching out", async () => {
|
|
game.override.enemyMoveset(Moves.INSTRUCT).enemySpecies(Species.UNOWN);
|
|
await game.classicMode.startBattle([Species.AMOONGUSS, Species.TOXICROAK]);
|
|
|
|
const amoonguss = game.scene.getPlayerPokemon()!;
|
|
game.move.changeMoveset(amoonguss, Moves.SEED_BOMB);
|
|
|
|
amoonguss.pushMoveHistory({
|
|
move: Moves.SEED_BOMB,
|
|
targets: [BattlerIndex.ENEMY],
|
|
result: MoveResult.SUCCESS,
|
|
useType: MoveUseType.NORMAL,
|
|
});
|
|
|
|
game.doSwitchPokemon(1);
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
const enemyMoves = game.scene.getEnemyPokemon()?.getLastXMoves(-1)!;
|
|
expect(enemyMoves?.[0]?.result).toBe(MoveResult.FAIL);
|
|
});
|
|
|
|
it("should fail if no move has yet been used by target", async () => {
|
|
game.override.moveset(Moves.INSTRUCT).enemyMoveset(Moves.SPLASH);
|
|
await game.classicMode.startBattle([Species.AMOONGUSS]);
|
|
|
|
game.move.select(Moves.INSTRUCT);
|
|
await game.move.selectEnemyMove(Moves.SPLASH);
|
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
expect(game.scene.getPlayerPokemon()!.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
|
});
|
|
|
|
it("should attempt to call enemy's disabled move, but move use itself should fail", async () => {
|
|
game.override.moveset([Moves.INSTRUCT, Moves.DISABLE]).battleStyle("double");
|
|
await game.classicMode.startBattle([Species.AMOONGUSS, Species.DROWZEE]);
|
|
|
|
const [enemy1, enemy2] = game.scene.getEnemyField();
|
|
game.move.changeMoveset(enemy1, Moves.SONIC_BOOM);
|
|
game.move.changeMoveset(enemy2, Moves.SPLASH);
|
|
|
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
|
game.move.select(Moves.DISABLE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
|
|
await game.move.selectEnemyMove(Moves.SONIC_BOOM, BattlerIndex.PLAYER);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2]);
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
expect(game.scene.getPlayerPokemon()!.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
|
expect(enemy1.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
|
expect(enemy1.getMoveset().find(m => m.moveId === Moves.SONIC_BOOM)?.ppUsed).toBe(1);
|
|
});
|
|
|
|
it("should not repeat enemy's move through protect", async () => {
|
|
game.override.moveset([Moves.INSTRUCT]);
|
|
await game.classicMode.startBattle([Species.AMOONGUSS]);
|
|
|
|
const enemy = game.scene.getEnemyPokemon()!;
|
|
game.move.changeMoveset(enemy, Moves.PROTECT);
|
|
game.move.select(Moves.INSTRUCT);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
expect(enemy.getLastXMoves(-1)[0].move).toBe(Moves.PROTECT);
|
|
expect(enemy.getLastXMoves(-1)[1]).toBeUndefined(); // undefined because instruct failed and didn't repeat
|
|
expect(enemy.getMoveset().find(m => m?.moveId === Moves.PROTECT)?.ppUsed).toBe(1);
|
|
});
|
|
|
|
it("should not repeat enemy's charging move", async () => {
|
|
game.override.moveset([Moves.INSTRUCT]).enemyMoveset([Moves.SONIC_BOOM, Moves.HYPER_BEAM]);
|
|
await game.classicMode.startBattle([Species.SHUCKLE]);
|
|
|
|
const player = game.scene.getPlayerPokemon()!;
|
|
const enemy = game.scene.getEnemyPokemon()!;
|
|
enemy.pushMoveHistory({
|
|
move: Moves.SONIC_BOOM,
|
|
targets: [BattlerIndex.PLAYER],
|
|
result: MoveResult.SUCCESS,
|
|
useType: MoveUseType.NORMAL,
|
|
});
|
|
|
|
game.move.select(Moves.INSTRUCT);
|
|
await game.move.selectEnemyMove(Moves.HYPER_BEAM);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
await game.toNextTurn();
|
|
|
|
// instruct fails at copying last move due to charging turn (rather than instructing sonic boom)
|
|
expect(player.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
|
|
|
game.move.select(Moves.INSTRUCT);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
expect(player.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
|
});
|
|
|
|
it("should not repeat move since forgotten by target", async () => {
|
|
game.override.enemyMoveset(Moves.INSTRUCT);
|
|
await game.classicMode.startBattle([Species.REGIELEKI]);
|
|
|
|
const regieleki = game.scene.getPlayerPokemon()!;
|
|
regieleki.pushMoveHistory({
|
|
move: Moves.ELECTRO_DRIFT,
|
|
targets: [BattlerIndex.PLAYER],
|
|
result: MoveResult.SUCCESS,
|
|
virtual: false,
|
|
});
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
await game.toEndOfTurn();
|
|
expect(game.field.getEnemyPokemon().getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
|
});
|
|
|
|
it("should disregard priority of instructed move on use", async () => {
|
|
game.override.enemyMoveset([Moves.SPLASH, Moves.WHIRLWIND]).moveset(Moves.INSTRUCT);
|
|
await game.classicMode.startBattle([Species.LUCARIO, Species.BANETTE]);
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
enemyPokemon.pushMoveHistory({
|
|
move: Moves.WHIRLWIND,
|
|
targets: [BattlerIndex.PLAYER],
|
|
result: MoveResult.SUCCESS,
|
|
useType: MoveUseType.NORMAL,
|
|
});
|
|
|
|
game.move.select(Moves.INSTRUCT);
|
|
await game.move.selectEnemyMove(Moves.SPLASH);
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
// lucario instructed enemy whirlwind at 0 priority to switch itself out
|
|
const instructedMove = enemyPokemon.getLastXMoves(-1)[1];
|
|
expect(instructedMove.result).toBe(MoveResult.SUCCESS);
|
|
expect(instructedMove.move).toBe(Moves.WHIRLWIND);
|
|
expect(game.scene.getPlayerPokemon()?.species.speciesId).toBe(Species.BANETTE);
|
|
});
|
|
|
|
it("should respect moves' original priority for psychic terrain", async () => {
|
|
game.override
|
|
.battleStyle("double")
|
|
.moveset([Moves.QUICK_ATTACK, Moves.SPLASH, Moves.INSTRUCT])
|
|
.enemyMoveset([Moves.SPLASH, Moves.PSYCHIC_TERRAIN]);
|
|
await game.classicMode.startBattle([Species.BANETTE, Species.KLEFKI]);
|
|
|
|
const banette = game.scene.getPlayerPokemon()!;
|
|
|
|
game.move.select(Moves.QUICK_ATTACK, BattlerIndex.PLAYER, BattlerIndex.ENEMY); // succeeds due to terrain no
|
|
game.move.select(Moves.SPLASH, BattlerIndex.PLAYER_2);
|
|
await game.move.selectEnemyMove(Moves.SPLASH);
|
|
await game.move.selectEnemyMove(Moves.PSYCHIC_TERRAIN);
|
|
await game.toNextTurn();
|
|
expect(banette.getLastXMoves(-1)[0]).toEqual(
|
|
expect.objectContaining({
|
|
move: Moves.QUICK_ATTACK,
|
|
targets: [BattlerIndex.ENEMY],
|
|
result: MoveResult.SUCCESS,
|
|
}),
|
|
);
|
|
|
|
game.move.select(Moves.SPLASH, BattlerIndex.PLAYER);
|
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER);
|
|
await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]);
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
// quick attack failed when instructed
|
|
expect(banette.getLastXMoves(-1)[1].move).toBe(Moves.QUICK_ATTACK);
|
|
expect(banette.getLastXMoves(-1)[1].result).toBe(MoveResult.FAIL);
|
|
});
|
|
|
|
// TODO: Enable once Sky Drop is fully implemented
|
|
it.todo("should not work against Sky Dropped targets, even if user/target have No Guard", async () => {
|
|
game.override.battleStyle("double").ability(Abilities.NO_GUARD);
|
|
await game.classicMode.startBattle([Species.BANETTE, Species.KLEFKI]);
|
|
|
|
const [banette, klefki] = game.scene.getPlayerField();
|
|
banette.pushMoveHistory({
|
|
move: Moves.VINE_WHIP,
|
|
targets: [BattlerIndex.ENEMY],
|
|
result: MoveResult.SUCCESS,
|
|
useType: MoveUseType.NORMAL,
|
|
});
|
|
|
|
// Attempt to instruct banette after having been sent airborne
|
|
game.move.use(Moves.VINE_WHIP, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
|
game.move.use(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER);
|
|
await game.move.forceEnemyMove(Moves.SKY_DROP, BattlerIndex.PLAYER);
|
|
await game.move.forceEnemyMove(Moves.ASTONISH, BattlerIndex.PLAYER);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2]);
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
|
|
// Klefki instruct fails due to banette being airborne, even though it got hit prior
|
|
expect(banette.visible).toBe(false);
|
|
expect(banette.isFullHp()).toBe(false);
|
|
expect(klefki.getLastXMoves()[0]).toMatchObject({
|
|
move: Moves.INSTRUCT,
|
|
targets: [BattlerIndex.PLAYER],
|
|
result: MoveResult.FAIL,
|
|
});
|
|
});
|
|
|
|
it("should still work with prankster in psychic terrain", async () => {
|
|
game.override
|
|
.battleStyle("double")
|
|
.ability(Abilities.PRANKSTER)
|
|
.enemyMoveset(Moves.SPLASH)
|
|
.enemyAbility(Abilities.PSYCHIC_SURGE);
|
|
await game.classicMode.startBattle([Species.BANETTE, Species.KLEFKI]);
|
|
|
|
const [banette, klefki] = game.scene.getPlayerField();
|
|
game.move.changeMoveset(banette, [Moves.VINE_WHIP]);
|
|
game.move.changeMoveset(klefki, Moves.INSTRUCT);
|
|
banette.pushMoveHistory({
|
|
move: Moves.VINE_WHIP,
|
|
targets: [BattlerIndex.ENEMY],
|
|
result: MoveResult.SUCCESS,
|
|
useType: MoveUseType.NORMAL,
|
|
});
|
|
|
|
game.move.select(Moves.VINE_WHIP, BattlerIndex.PLAYER);
|
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER); // copies vine whip
|
|
await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]);
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
// Klefki instructing a non-priority move succeeds, ignoring the priority of Instruct itself
|
|
expect(banette.getLastXMoves(-1)[1].move).toBe(Moves.VINE_WHIP);
|
|
expect(banette.getLastXMoves(-1)[2].move).toBe(Moves.VINE_WHIP);
|
|
expect(klefki.getLastXMoves(-1)[0]).toEqual(
|
|
expect.objectContaining({
|
|
move: Moves.INSTRUCT,
|
|
targets: [BattlerIndex.PLAYER],
|
|
result: MoveResult.SUCCESS,
|
|
}),
|
|
);
|
|
});
|
|
|
|
it("should cause spread moves to correctly hit targets in doubles after singles", async () => {
|
|
game.override
|
|
.battleStyle("even-doubles")
|
|
.moveset([Moves.BREAKING_SWIPE, Moves.INSTRUCT, Moves.SPLASH])
|
|
.enemyMoveset(Moves.SONIC_BOOM)
|
|
.enemySpecies(Species.AXEW)
|
|
.startingLevel(500)
|
|
.enemyLevel(1);
|
|
await game.classicMode.startBattle([Species.KORAIDON, Species.KLEFKI]);
|
|
|
|
const koraidon = game.scene.getPlayerField()[0]!;
|
|
|
|
game.move.select(Moves.BREAKING_SWIPE);
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
expect(koraidon.hp).toBe(koraidon.getMaxHp());
|
|
expect(koraidon.getLastXMoves(-1)[0].targets).toEqual([BattlerIndex.ENEMY]);
|
|
await game.toNextWave();
|
|
|
|
game.move.select(Moves.SPLASH, BattlerIndex.PLAYER);
|
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER);
|
|
await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]);
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
// did not take damage since enemies died beforehand;
|
|
// last move used hit both enemies
|
|
expect(koraidon.hp).toBe(koraidon.getMaxHp());
|
|
expect(koraidon.getLastXMoves(-1)[1].targets?.sort()).toEqual([BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]);
|
|
});
|
|
|
|
it("should cause AoE moves to correctly hit everyone in doubles after singles", async () => {
|
|
game.override
|
|
.battleStyle("even-doubles")
|
|
.moveset([Moves.BRUTAL_SWING, Moves.INSTRUCT, Moves.SPLASH])
|
|
.enemySpecies(Species.AXEW)
|
|
.enemyMoveset(Moves.SONIC_BOOM)
|
|
.startingLevel(500)
|
|
.enemyLevel(1);
|
|
await game.classicMode.startBattle([Species.KORAIDON, Species.KLEFKI]);
|
|
|
|
const koraidon = game.scene.getPlayerField()[0]!;
|
|
|
|
game.move.select(Moves.BRUTAL_SWING);
|
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
expect(koraidon.hp).toBe(koraidon.getMaxHp());
|
|
expect(koraidon.getLastXMoves(-1)[0].targets).toEqual([BattlerIndex.ENEMY]);
|
|
|
|
await game.toNextWave();
|
|
|
|
game.move.select(Moves.SPLASH, BattlerIndex.PLAYER);
|
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER);
|
|
await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]);
|
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
|
|
|
// did not take damage since enemies died beforehand;
|
|
// last move used hit everything around it
|
|
expect(koraidon.hp).toBe(koraidon.getMaxHp());
|
|
expect(koraidon.getLastXMoves(-1)[1].targets).toHaveLength(3);
|
|
expect(koraidon.getLastXMoves(-1)[1].targets).toEqual(
|
|
expect.arrayContaining([BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]),
|
|
);
|
|
});
|
|
|
|
it("should cause multi-hit moves to hit the appropriate number of times in singles", async () => {
|
|
game.override
|
|
.enemyAbility(Abilities.SKILL_LINK)
|
|
.moveset([Moves.SPLASH, Moves.INSTRUCT])
|
|
.enemyMoveset(Moves.BULLET_SEED);
|
|
await game.classicMode.startBattle([Species.BULBASAUR]);
|
|
|
|
const bulbasaur = game.scene.getPlayerPokemon()!;
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
await game.toNextTurn();
|
|
|
|
game.move.select(Moves.INSTRUCT);
|
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
expect(bulbasaur.turnData.attacksReceived.length).toBe(10);
|
|
|
|
await game.toNextTurn();
|
|
game.move.select(Moves.INSTRUCT);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
expect(bulbasaur.turnData.attacksReceived.length).toBe(10);
|
|
});
|
|
|
|
it("should cause multi-hit moves to hit the appropriate number of times in doubles", async () => {
|
|
game.override
|
|
.battleStyle("double")
|
|
.enemyAbility(Abilities.SKILL_LINK)
|
|
.moveset([Moves.SPLASH, Moves.INSTRUCT])
|
|
.enemyMoveset([Moves.BULLET_SEED, Moves.SPLASH])
|
|
.enemyLevel(5);
|
|
await game.classicMode.startBattle([Species.BULBASAUR, Species.IVYSAUR]);
|
|
|
|
const [, ivysaur] = game.scene.getPlayerField();
|
|
|
|
game.move.select(Moves.SPLASH, BattlerIndex.PLAYER);
|
|
game.move.select(Moves.SPLASH, BattlerIndex.PLAYER_2);
|
|
await game.move.selectEnemyMove(Moves.BULLET_SEED, BattlerIndex.PLAYER_2);
|
|
await game.move.selectEnemyMove(Moves.SPLASH);
|
|
await game.toNextTurn();
|
|
|
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
|
|
await game.move.selectEnemyMove(Moves.BULLET_SEED, BattlerIndex.PLAYER_2);
|
|
await game.move.selectEnemyMove(Moves.SPLASH);
|
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]);
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
expect(ivysaur.turnData.attacksReceived.length).toBe(15);
|
|
|
|
await game.toNextTurn();
|
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
|
|
await game.move.selectEnemyMove(Moves.BULLET_SEED, BattlerIndex.PLAYER_2);
|
|
await game.move.selectEnemyMove(Moves.SPLASH);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2]);
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
expect(ivysaur.turnData.attacksReceived.length).toBe(15);
|
|
});
|
|
});
|