mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-10-22 13:05:51 +02:00
* Added `MoveUseType` and refactored MEP * Fixed Wimp out tests & ME code finally i think all the booleans are gone i hope * Added version migration for last resort and co. buh gumbug * Fixed various bugs and added tests for previous bugfixes * Reverted a couple doc changes * WIP * Update pokemon-species.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update pokemon-phase.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Fixed remaining tests (I think) * Reverted rollout test changes * Fixed command phase bug causing metronome test timeout * Revert early_bird.test.ts * Fix biome.jsonc * Made `MoveUseType` start at 1 As per @DayKev's request * Fixed a thing * Fixed bolt beak condition to be marginally less jank * Applied some review suggestions * Reverted move phase operations * Added helper functions complete with markdown tables * Fixed things * Update battler-tags.ts * Fixed random issues * Fixed code * Fixed comment * Fixed import issues * Fix disable.test.ts conflicts * Update instruct.test.ts * Update `biome.jsonc` * Renamed `MoveUseType` to `MoveUseMode`; applied review comments * Fixed space * Fixed phasemanager bugs * Fixed instruct test to not bork * Fixed gorilla tactics bug * Battler Tags doc fixes * Fixed formatting and suttff * Minor comment updates and remove unused imports in `move.ts` * Re-add `public`, remove unnecessary default value in `battler-tags.ts` * Restore `{}` in `turn-start-phase.ts` Fixes `lint/correctness/noSwitchDeclarations` * Remove extra space in TSDoc in `move-phase.ts` * Use `game.field` instead of `game.scene` in `instruct.test.ts` Also `game.toEndOfTurn()` instead of `game.phaseInterceptor.to("BerryPhase")` * Use `game.field` instead of `game.scene` in `metronome.test.ts` * Use `toEndOfTurn()` instead of `to("BerryPhase")` in `powder.test.ts` * Convert `MoveUseMode` enum to `const` object * Update move-phase.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Add `enumValueToKey` utility function * Apply Biome --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
169 lines
6.0 KiB
TypeScript
169 lines
6.0 KiB
TypeScript
import { BattlerIndex } from "#enums/battler-index";
|
|
import { MoveResult } from "#enums/move-result";
|
|
import { AbilityId } from "#enums/ability-id";
|
|
import { MoveUseMode } from "#enums/move-use-mode";
|
|
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, it } from "vitest";
|
|
|
|
describe("Moves - Last Resort", () => {
|
|
let phaserGame: Phaser.Game;
|
|
let game: GameManager;
|
|
|
|
function expectLastResortFail() {
|
|
expect(game.scene.getPlayerPokemon()?.getLastXMoves()[0]).toEqual(
|
|
expect.objectContaining({
|
|
move: MoveId.LAST_RESORT,
|
|
result: MoveResult.FAIL,
|
|
}),
|
|
);
|
|
}
|
|
beforeAll(() => {
|
|
phaserGame = new Phaser.Game({
|
|
type: Phaser.HEADLESS,
|
|
});
|
|
});
|
|
|
|
afterEach(() => {
|
|
game.phaseInterceptor.restoreOg();
|
|
});
|
|
|
|
beforeEach(() => {
|
|
game = new GameManager(phaserGame);
|
|
game.override
|
|
.ability(AbilityId.BALL_FETCH)
|
|
.battleStyle("single")
|
|
.disableCrits()
|
|
.enemySpecies(SpeciesId.MAGIKARP)
|
|
.enemyAbility(AbilityId.BALL_FETCH)
|
|
.enemyMoveset(MoveId.SPLASH);
|
|
});
|
|
|
|
it("should fail unless all other moves (excluding itself) has been used at least once", async () => {
|
|
game.override.moveset([MoveId.LAST_RESORT, MoveId.SPLASH, MoveId.GROWL, MoveId.GROWTH]);
|
|
await game.classicMode.startBattle([SpeciesId.BLISSEY]);
|
|
|
|
const blissey = game.scene.getPlayerPokemon()!;
|
|
expect(blissey).toBeDefined();
|
|
|
|
// Last resort by itself
|
|
game.move.select(MoveId.LAST_RESORT);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
expectLastResortFail();
|
|
|
|
// Splash (1/3)
|
|
blissey.pushMoveHistory({ move: MoveId.SPLASH, targets: [BattlerIndex.PLAYER], useMode: MoveUseMode.NORMAL });
|
|
game.move.select(MoveId.LAST_RESORT);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
expectLastResortFail();
|
|
|
|
// Growl (2/3)
|
|
blissey.pushMoveHistory({ move: MoveId.GROWL, targets: [BattlerIndex.ENEMY], useMode: MoveUseMode.NORMAL });
|
|
game.move.select(MoveId.LAST_RESORT);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
expectLastResortFail(); // Were last resort itself counted, it would error here
|
|
|
|
// Growth (3/3)
|
|
blissey.pushMoveHistory({ move: MoveId.GROWTH, targets: [BattlerIndex.PLAYER], useMode: MoveUseMode.NORMAL });
|
|
game.move.select(MoveId.LAST_RESORT);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
expect(game.scene.getPlayerPokemon()?.getLastXMoves()[0]).toEqual(
|
|
expect.objectContaining({
|
|
move: MoveId.LAST_RESORT,
|
|
result: MoveResult.SUCCESS,
|
|
}),
|
|
);
|
|
});
|
|
|
|
it("should disregard virtually invoked moves", async () => {
|
|
game.override
|
|
.moveset([MoveId.LAST_RESORT, MoveId.SWORDS_DANCE, MoveId.ABSORB, MoveId.MIRROR_MOVE])
|
|
.enemyMoveset([MoveId.SWORDS_DANCE, MoveId.ABSORB])
|
|
.ability(AbilityId.DANCER)
|
|
.enemySpecies(SpeciesId.ABOMASNOW); // magikarp has 50% chance to be okho'd on absorb crit
|
|
await game.classicMode.startBattle([SpeciesId.BLISSEY]);
|
|
|
|
// use mirror move normally to trigger absorb virtually
|
|
game.move.select(MoveId.MIRROR_MOVE);
|
|
await game.move.selectEnemyMove(MoveId.ABSORB);
|
|
await game.toNextTurn();
|
|
|
|
game.move.select(MoveId.LAST_RESORT);
|
|
await game.move.selectEnemyMove(MoveId.SWORDS_DANCE); // goes first to proc dancer ahead of time
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
expectLastResortFail();
|
|
});
|
|
|
|
it("should fail if no other moves in moveset", async () => {
|
|
game.override.moveset(MoveId.LAST_RESORT);
|
|
await game.classicMode.startBattle([SpeciesId.BLISSEY]);
|
|
|
|
game.move.select(MoveId.LAST_RESORT);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
expectLastResortFail();
|
|
});
|
|
|
|
it("should work if invoked virtually when all other moves have been used", async () => {
|
|
game.override.moveset([MoveId.LAST_RESORT, MoveId.SLEEP_TALK]).ability(AbilityId.COMATOSE);
|
|
await game.classicMode.startBattle([SpeciesId.KOMALA]);
|
|
|
|
game.move.select(MoveId.SLEEP_TALK);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
expect(game.scene.getPlayerPokemon()?.getLastXMoves(-1)).toEqual([
|
|
expect.objectContaining({
|
|
move: MoveId.LAST_RESORT,
|
|
result: MoveResult.SUCCESS,
|
|
useMode: MoveUseMode.FOLLOW_UP,
|
|
}),
|
|
expect.objectContaining({
|
|
move: MoveId.SLEEP_TALK,
|
|
result: MoveResult.SUCCESS,
|
|
useMode: MoveUseMode.NORMAL,
|
|
}),
|
|
]);
|
|
});
|
|
|
|
it("should preserve usability status on reload", async () => {
|
|
game.override.moveset([MoveId.LAST_RESORT, MoveId.SPLASH]).ability(AbilityId.COMATOSE);
|
|
await game.classicMode.startBattle([SpeciesId.BLISSEY]);
|
|
|
|
game.move.select(MoveId.SPLASH);
|
|
await game.doKillOpponents();
|
|
await game.toNextWave();
|
|
|
|
const oldMoveHistory = game.scene.getPlayerPokemon()?.summonData.moveHistory;
|
|
await game.reload.reloadSession();
|
|
|
|
const newMoveHistory = game.scene.getPlayerPokemon()?.summonData.moveHistory;
|
|
expect(oldMoveHistory).toEqual(newMoveHistory);
|
|
|
|
// use last resort and it should kill the karp just fine
|
|
game.move.select(MoveId.LAST_RESORT);
|
|
game.scene.getEnemyPokemon()!.hp = 1;
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
expect(game.isVictory()).toBe(true);
|
|
});
|
|
|
|
it("should fail if used while not in moveset", async () => {
|
|
game.override.moveset(MoveId.MIRROR_MOVE).enemyMoveset([MoveId.ABSORB, MoveId.LAST_RESORT]);
|
|
await game.classicMode.startBattle([SpeciesId.BLISSEY]);
|
|
|
|
// ensure enemy last resort succeeds
|
|
game.move.select(MoveId.MIRROR_MOVE);
|
|
await game.move.selectEnemyMove(MoveId.ABSORB);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
game.move.select(MoveId.MIRROR_MOVE);
|
|
await game.move.selectEnemyMove(MoveId.LAST_RESORT);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
expectLastResortFail();
|
|
});
|
|
});
|