pokerogue/test/moves/follow_me.test.ts

130 lines
4.4 KiB
TypeScript
Raw Normal View History

[Refactor/Bug/Move] Overhaul Stats and Battle Items, Implement Several Stat Moves (#2699) * Create Getters, Setters, and Types * Work on `pokemon.ts` * Adjust Types, Refactor `White Herb` Modifier * Migrate `TempBattleStat` Usage * Refactor `PokemonBaseStatModifier` Slightly * Remove `BattleStat`, Use "Stat Stages" & New Names * Address Phase `integers` * Finalize `BattleStat` Removal * Address Minor Manual NITs * Apply Own Review Suggestions * Fix Syntax Error * Add Docs * Overhaul X Items * Implement Guard and Power Split with Unit Tests * Add Several Unit Tests and Fixes * Implement Speed Swap with Unit Tests * Fix Keys in Summary Menu * Fix Starf Berry Raising EVA and ACC * Fix Contrary & Simple, Verify with Unit Tests * Implement Power & Guard Swap with Unit Tests * Add Move Effect Message to Speed Swap * Add Move Effect Message to Power & Guard Split * Add Localization Entries * Adjust Last X Item Unit Test * Overhaul X Items Unit Tests * Finish Missing Docs * Revamp Crit-Based Unit Tests & Dire Hit * Address Initial NITs * Apply NIT Batch Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Fix Moody Test * Address Multiple Messages for `ProtectStatAbAttr` * Change `ignoreOverride` to `bypassSummonData` * Adjust Italian Localization Co-authored-by: Niccolò <123510358+NicusPulcis@users.noreply.github.com> * Fix Moody --------- Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: Niccolò <123510358+NicusPulcis@users.noreply.github.com>
2024-09-02 22:12:34 -04:00
import { Stat } from "#enums/stat";
import { BattlerIndex } from "#app/battle";
import { Abilities } from "#app/enums/abilities";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
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";
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);
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 ]);
});
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 ]);
const playerPokemon = game.scene.getPlayerField();
game.move.select(Moves.FOLLOW_ME);
game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY);
// 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);
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 () => {
2024-10-04 13:08:31 +08:00
await game.classicMode.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]);
const playerPokemon = game.scene.getPlayerField();
game.move.select(Moves.FOLLOW_ME);
game.move.select(Moves.FOLLOW_ME, 1);
// Each player is targeted by an enemy
await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER);
await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to(TurnEndPhase, false);
[Refactor/Bug/Move] Overhaul Stats and Battle Items, Implement Several Stat Moves (#2699) * Create Getters, Setters, and Types * Work on `pokemon.ts` * Adjust Types, Refactor `White Herb` Modifier * Migrate `TempBattleStat` Usage * Refactor `PokemonBaseStatModifier` Slightly * Remove `BattleStat`, Use "Stat Stages" & New Names * Address Phase `integers` * Finalize `BattleStat` Removal * Address Minor Manual NITs * Apply Own Review Suggestions * Fix Syntax Error * Add Docs * Overhaul X Items * Implement Guard and Power Split with Unit Tests * Add Several Unit Tests and Fixes * Implement Speed Swap with Unit Tests * Fix Keys in Summary Menu * Fix Starf Berry Raising EVA and ACC * Fix Contrary & Simple, Verify with Unit Tests * Implement Power & Guard Swap with Unit Tests * Add Move Effect Message to Speed Swap * Add Move Effect Message to Power & Guard Split * Add Localization Entries * Adjust Last X Item Unit Test * Overhaul X Items Unit Tests * Finish Missing Docs * Revamp Crit-Based Unit Tests & Dire Hit * Address Initial NITs * Apply NIT Batch Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Fix Moody Test * Address Multiple Messages for `ProtectStatAbAttr` * Change `ignoreOverride` to `bypassSummonData` * Adjust Italian Localization Co-authored-by: Niccolò <123510358+NicusPulcis@users.noreply.github.com> * Fix Moody --------- Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: Niccolò <123510358+NicusPulcis@users.noreply.github.com>
2024-09-02 22:12:34 -04:00
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 () => {
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-10-04 13:08:31 +08:00
await game.classicMode.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]);
const enemyPokemon = game.scene.getEnemyField();
game.move.select(Moves.QUICK_ATTACK, 0, BattlerIndex.ENEMY);
game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY_2);
// Target doesn't need to be specified if the move is self-targeted
await game.forceEnemyMove(Moves.FOLLOW_ME);
await game.forceEnemyMove(Moves.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 () => {
2024-10-04 13:08:31 +08:00
game.override.moveset([ Moves.SNIPE_SHOT ]);
2024-10-04 13:08:31 +08:00
await game.classicMode.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]);
const enemyPokemon = game.scene.getEnemyField();
game.move.select(Moves.SNIPE_SHOT, 0, BattlerIndex.ENEMY);
game.move.select(Moves.SNIPE_SHOT, 1, BattlerIndex.ENEMY_2);
await game.forceEnemyMove(Moves.FOLLOW_ME);
await game.forceEnemyMove(Moves.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());
}
);
});