pokerogue/test/moves/follow_me.test.ts
NightKev 9dcb904649
[Misc] Improve enum naming (#5933)
* Rename `Abilities` to `AbilityId`

* Rename `abilities.ts` to `ability-id.ts`

* Rename `Moves` to `MoveId`

* Rename `moves.ts` to `move-id.ts`

* Rename `Species` to `SpeciesId`

* Rename `species.ts` to `species-id.ts`

* Rename `Biome` to `BiomeId`

* Rename `biome.ts` to `biome-id.ts`

* Replace `Abilities` with `AbilityId` in comments

* Replace `Biome` with `BiomeId` in comments

* Replace `Moves` with `MoveId` in comments

* Replace `Species` with `SpeciesId` in comments
2025-06-04 14:54:27 -07:00

117 lines
4.4 KiB
TypeScript

import { Stat } from "#enums/stat";
import { BattlerIndex } from "#app/battle";
import { AbilityId } from "#enums/ability-id";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id";
import GameManager from "#test/testUtils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
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);
game.override.battleStyle("double");
game.override.starterSpecies(SpeciesId.AMOONGUSS);
game.override.ability(AbilityId.BALL_FETCH);
game.override.enemySpecies(SpeciesId.SNORLAX);
game.override.startingLevel(100);
game.override.enemyLevel(100);
game.override.moveset([MoveId.FOLLOW_ME, MoveId.RAGE_POWDER, MoveId.SPOTLIGHT, MoveId.QUICK_ATTACK]);
game.override.enemyMoveset([MoveId.TACKLE, MoveId.FOLLOW_ME, MoveId.SPLASH]);
});
test("move should redirect enemy attacks to the user", async () => {
await game.classicMode.startBattle([SpeciesId.AMOONGUSS, SpeciesId.CHARIZARD]);
const playerPokemon = game.scene.getPlayerField();
game.move.select(MoveId.FOLLOW_ME);
game.move.select(MoveId.QUICK_ATTACK, 1, BattlerIndex.ENEMY);
// Force both enemies to target the player Pokemon that did not use Follow Me
await game.move.selectEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER_2);
await game.move.selectEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to(TurnEndPhase, false);
expect(playerPokemon[0].hp).toBeLessThan(playerPokemon[0].getMaxHp());
expect(playerPokemon[1].hp).toBe(playerPokemon[1].getMaxHp());
});
test("move should redirect enemy attacks to the first ally that uses it", async () => {
await game.classicMode.startBattle([SpeciesId.AMOONGUSS, SpeciesId.CHARIZARD]);
const playerPokemon = game.scene.getPlayerField();
game.move.select(MoveId.FOLLOW_ME);
game.move.select(MoveId.FOLLOW_ME, 1);
// Each player is targeted by an enemy
await game.move.selectEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER);
await game.move.selectEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to(TurnEndPhase, false);
playerPokemon.sort((a, b) => a.getEffectiveStat(Stat.SPD) - b.getEffectiveStat(Stat.SPD));
expect(playerPokemon[1].hp).toBeLessThan(playerPokemon[1].getMaxHp());
expect(playerPokemon[0].hp).toBe(playerPokemon[0].getMaxHp());
});
test("move effect should be bypassed by Stalwart", async () => {
game.override.ability(AbilityId.STALWART);
game.override.moveset([MoveId.QUICK_ATTACK]);
await game.classicMode.startBattle([SpeciesId.AMOONGUSS, SpeciesId.CHARIZARD]);
const enemyPokemon = game.scene.getEnemyField();
game.move.select(MoveId.QUICK_ATTACK, 0, BattlerIndex.ENEMY);
game.move.select(MoveId.QUICK_ATTACK, 1, BattlerIndex.ENEMY_2);
// Target doesn't need to be specified if the move is self-targeted
await game.move.selectEnemyMove(MoveId.FOLLOW_ME);
await game.move.selectEnemyMove(MoveId.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase, false);
// If redirection was bypassed, both enemies should be damaged
expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp());
expect(enemyPokemon[1].hp).toBeLessThan(enemyPokemon[1].getMaxHp());
});
test("move effect should be bypassed by Snipe Shot", async () => {
game.override.moveset([MoveId.SNIPE_SHOT]);
await game.classicMode.startBattle([SpeciesId.AMOONGUSS, SpeciesId.CHARIZARD]);
const enemyPokemon = game.scene.getEnemyField();
game.move.select(MoveId.SNIPE_SHOT, 0, BattlerIndex.ENEMY);
game.move.select(MoveId.SNIPE_SHOT, 1, BattlerIndex.ENEMY_2);
await game.move.selectEnemyMove(MoveId.FOLLOW_ME);
await game.move.selectEnemyMove(MoveId.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase, false);
// If redirection was bypassed, both enemies should be damaged
expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp());
expect(enemyPokemon[1].hp).toBeLessThan(enemyPokemon[1].getMaxHp());
});
});