2024-09-02 22:12:34 -04:00
|
|
|
import { Stat } from "#enums/stat";
|
2024-08-22 06:49:33 -07:00
|
|
|
import { BattlerIndex } from "#app/battle";
|
|
|
|
import { Abilities } from "#app/enums/abilities";
|
|
|
|
import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
2024-06-17 15:05:21 -07:00
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
2025-02-22 22:52:07 -06:00
|
|
|
import GameManager from "#test/testUtils/gameManager";
|
2024-07-25 16:10:38 -07:00
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
|
2024-06-17 15:05:21 -07:00
|
|
|
|
2024-09-20 14:05:45 -07:00
|
|
|
|
2024-06-17 15:05:21 -07:00
|
|
|
describe("Moves - Follow Me", () => {
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
let game: GameManager;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
phaserGame = new Phaser.Game({
|
|
|
|
type: Phaser.HEADLESS,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
game.phaseInterceptor.restoreOg();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
game = new GameManager(phaserGame);
|
2024-07-25 14:48:48 -07:00
|
|
|
game.override.battleType("double");
|
2024-07-25 15:24:07 -07:00
|
|
|
game.override.starterSpecies(Species.AMOONGUSS);
|
2024-09-04 10:56:57 -07:00
|
|
|
game.override.ability(Abilities.BALL_FETCH);
|
2024-07-25 14:57:47 -07:00
|
|
|
game.override.enemySpecies(Species.SNORLAX);
|
2024-07-25 15:29:19 -07:00
|
|
|
game.override.startingLevel(100);
|
2024-07-25 16:10:38 -07:00
|
|
|
game.override.enemyLevel(100);
|
2024-10-04 13:08:31 +08:00
|
|
|
game.override.moveset([ Moves.FOLLOW_ME, Moves.RAGE_POWDER, Moves.SPOTLIGHT, Moves.QUICK_ATTACK ]);
|
|
|
|
game.override.enemyMoveset([ Moves.TACKLE, Moves.FOLLOW_ME, Moves.SPLASH ]);
|
2024-06-17 15:05:21 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
test(
|
|
|
|
"move should redirect enemy attacks to the user",
|
|
|
|
async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]);
|
2024-06-17 15:05:21 -07:00
|
|
|
|
|
|
|
const playerPokemon = game.scene.getPlayerField();
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.FOLLOW_ME);
|
|
|
|
game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY);
|
2024-09-04 10:56:57 -07:00
|
|
|
|
|
|
|
// Force both enemies to target the player Pokemon that did not use Follow Me
|
|
|
|
await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER_2);
|
|
|
|
await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER_2);
|
|
|
|
|
2024-06-20 02:11:29 -07:00
|
|
|
await game.phaseInterceptor.to(TurnEndPhase, false);
|
2024-06-17 15:05:21 -07:00
|
|
|
|
2024-09-04 10:56:57 -07:00
|
|
|
expect(playerPokemon[0].hp).toBeLessThan(playerPokemon[0].getMaxHp());
|
|
|
|
expect(playerPokemon[1].hp).toBe(playerPokemon[1].getMaxHp());
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-06-17 15:05:21 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
|
|
|
"move should redirect enemy attacks to the first ally that uses it",
|
|
|
|
async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]);
|
2024-06-17 15:05:21 -07:00
|
|
|
|
|
|
|
const playerPokemon = game.scene.getPlayerField();
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.FOLLOW_ME);
|
|
|
|
game.move.select(Moves.FOLLOW_ME, 1);
|
2024-09-04 10:56:57 -07:00
|
|
|
|
|
|
|
// Each player is targeted by an enemy
|
|
|
|
await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER);
|
|
|
|
await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER_2);
|
|
|
|
|
2024-06-20 02:11:29 -07:00
|
|
|
await game.phaseInterceptor.to(TurnEndPhase, false);
|
2024-06-17 15:05:21 -07:00
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
playerPokemon.sort((a, b) => a.getEffectiveStat(Stat.SPD) - b.getEffectiveStat(Stat.SPD));
|
2024-06-17 15:05:21 -07:00
|
|
|
|
2024-09-04 10:56:57 -07:00
|
|
|
expect(playerPokemon[1].hp).toBeLessThan(playerPokemon[1].getMaxHp());
|
|
|
|
expect(playerPokemon[0].hp).toBe(playerPokemon[0].getMaxHp());
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-06-17 15:05:21 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
|
|
|
"move effect should be bypassed by Stalwart",
|
|
|
|
async () => {
|
2024-07-25 15:35:20 -07:00
|
|
|
game.override.ability(Abilities.STALWART);
|
2024-10-04 13:08:31 +08:00
|
|
|
game.override.moveset([ Moves.QUICK_ATTACK ]);
|
2024-06-17 15:05:21 -07:00
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]);
|
2024-06-17 15:05:21 -07:00
|
|
|
|
|
|
|
const enemyPokemon = game.scene.getEnemyField();
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.QUICK_ATTACK, 0, BattlerIndex.ENEMY);
|
|
|
|
game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY_2);
|
2024-09-04 10:56:57 -07:00
|
|
|
|
|
|
|
// Target doesn't need to be specified if the move is self-targeted
|
|
|
|
await game.forceEnemyMove(Moves.FOLLOW_ME);
|
|
|
|
await game.forceEnemyMove(Moves.SPLASH);
|
|
|
|
|
2024-06-20 02:11:29 -07:00
|
|
|
await game.phaseInterceptor.to(TurnEndPhase, false);
|
2024-06-17 15:05:21 -07:00
|
|
|
|
|
|
|
// If redirection was bypassed, both enemies should be damaged
|
2024-09-04 10:56:57 -07:00
|
|
|
expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp());
|
|
|
|
expect(enemyPokemon[1].hp).toBeLessThan(enemyPokemon[1].getMaxHp());
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-06-17 15:05:21 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
|
|
|
"move effect should be bypassed by Snipe Shot",
|
|
|
|
async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
game.override.moveset([ Moves.SNIPE_SHOT ]);
|
2024-06-17 15:05:21 -07:00
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]);
|
2024-06-17 15:05:21 -07:00
|
|
|
|
|
|
|
const enemyPokemon = game.scene.getEnemyField();
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.SNIPE_SHOT, 0, BattlerIndex.ENEMY);
|
|
|
|
game.move.select(Moves.SNIPE_SHOT, 1, BattlerIndex.ENEMY_2);
|
2024-09-04 10:56:57 -07:00
|
|
|
|
|
|
|
await game.forceEnemyMove(Moves.FOLLOW_ME);
|
|
|
|
await game.forceEnemyMove(Moves.SPLASH);
|
|
|
|
|
2024-06-20 02:11:29 -07:00
|
|
|
await game.phaseInterceptor.to(TurnEndPhase, false);
|
2024-06-17 15:05:21 -07:00
|
|
|
|
|
|
|
// If redirection was bypassed, both enemies should be damaged
|
2024-09-04 10:56:57 -07:00
|
|
|
expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp());
|
|
|
|
expect(enemyPokemon[1].hp).toBeLessThan(enemyPokemon[1].getMaxHp());
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-06-17 15:05:21 -07:00
|
|
|
);
|
|
|
|
});
|