mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 00:52:47 +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>
154 lines
5.7 KiB
TypeScript
154 lines
5.7 KiB
TypeScript
import { BattlerIndex } from "#enums/battler-index";
|
|
import { RechargingTag, SemiInvulnerableTag } from "#app/data/battler-tags";
|
|
import type { RandomMoveAttr } from "#app/data/moves/move";
|
|
import { allMoves } from "#app/data/data-lists";
|
|
import { AbilityId } from "#enums/ability-id";
|
|
import { Stat } from "#app/enums/stat";
|
|
import { MoveResult } from "#enums/move-result";
|
|
import { CommandPhase } from "#app/phases/command-phase";
|
|
import { BattlerTagType } from "#enums/battler-tag-type";
|
|
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, it, expect, vi } from "vitest";
|
|
|
|
describe("Moves - Metronome", () => {
|
|
let phaserGame: Phaser.Game;
|
|
let game: GameManager;
|
|
|
|
let randomMoveAttr: RandomMoveAttr;
|
|
|
|
beforeAll(() => {
|
|
phaserGame = new Phaser.Game({
|
|
type: Phaser.HEADLESS,
|
|
});
|
|
});
|
|
|
|
afterEach(() => {
|
|
game.phaseInterceptor.restoreOg();
|
|
});
|
|
|
|
beforeEach(() => {
|
|
randomMoveAttr = allMoves[MoveId.METRONOME].getAttrs("RandomMoveAttr")[0];
|
|
game = new GameManager(phaserGame);
|
|
game.override
|
|
.moveset([MoveId.METRONOME, MoveId.SPLASH])
|
|
.battleStyle("single")
|
|
.startingLevel(100)
|
|
.enemyLevel(100)
|
|
.enemySpecies(SpeciesId.SHUCKLE)
|
|
.enemyMoveset(MoveId.SPLASH)
|
|
.enemyAbility(AbilityId.BALL_FETCH);
|
|
});
|
|
|
|
it("should have one semi-invulnerable turn and deal damage on the second turn when a semi-invulnerable move is called", async () => {
|
|
await game.classicMode.startBattle([SpeciesId.REGIELEKI]);
|
|
const player = game.scene.getPlayerPokemon()!;
|
|
const enemy = game.scene.getEnemyPokemon()!;
|
|
vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(MoveId.DIVE);
|
|
|
|
game.move.select(MoveId.METRONOME);
|
|
await game.toNextTurn();
|
|
|
|
expect(player.getTag(SemiInvulnerableTag)).toBeTruthy();
|
|
|
|
await game.toNextTurn();
|
|
expect(player.getTag(SemiInvulnerableTag)).toBeFalsy();
|
|
expect(enemy.isFullHp()).toBeFalsy();
|
|
});
|
|
|
|
it("should apply secondary effects of a move", async () => {
|
|
await game.classicMode.startBattle([SpeciesId.REGIELEKI]);
|
|
const player = game.scene.getPlayerPokemon()!;
|
|
vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(MoveId.WOOD_HAMMER);
|
|
|
|
game.move.select(MoveId.METRONOME);
|
|
await game.toNextTurn();
|
|
|
|
expect(player.isFullHp()).toBeFalsy();
|
|
});
|
|
|
|
it("should recharge after using recharge move", async () => {
|
|
await game.classicMode.startBattle([SpeciesId.REGIELEKI]);
|
|
const player = game.scene.getPlayerPokemon()!;
|
|
vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(MoveId.HYPER_BEAM);
|
|
vi.spyOn(allMoves[MoveId.HYPER_BEAM], "accuracy", "get").mockReturnValue(100);
|
|
|
|
game.move.select(MoveId.METRONOME);
|
|
await game.toNextTurn();
|
|
|
|
expect(player.getTag(RechargingTag)).toBeTruthy();
|
|
});
|
|
|
|
it("should charge for charging moves while still maintaining follow-up status", async () => {
|
|
game.override.moveset([]).enemyMoveset(MoveId.SPITE);
|
|
vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(MoveId.SOLAR_BEAM);
|
|
await game.classicMode.startBattle([SpeciesId.REGIELEKI]);
|
|
|
|
const player = game.field.getPlayerPokemon();
|
|
game.move.changeMoveset(player, [MoveId.METRONOME, MoveId.SOLAR_BEAM]);
|
|
|
|
const [metronomeMove, solarBeamMove] = player.getMoveset();
|
|
expect(metronomeMove).toBeDefined();
|
|
expect(solarBeamMove).toBeDefined();
|
|
|
|
game.move.select(MoveId.METRONOME);
|
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
expect(player.getTag(BattlerTagType.CHARGING)).toBeTruthy();
|
|
const turn1PpUsed = metronomeMove.ppUsed;
|
|
expect.soft(turn1PpUsed).toBeGreaterThan(1);
|
|
expect(solarBeamMove.ppUsed).toBe(0);
|
|
|
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
await game.toNextTurn();
|
|
|
|
expect(player.getTag(BattlerTagType.CHARGING)).toBeFalsy();
|
|
const turn2PpUsed = metronomeMove.ppUsed - turn1PpUsed;
|
|
expect(turn2PpUsed).toBeGreaterThan(1);
|
|
expect(solarBeamMove.ppUsed).toBe(0);
|
|
expect(player.getLastXMoves()[0]).toMatchObject({
|
|
move: MoveId.SOLAR_BEAM,
|
|
result: MoveResult.SUCCESS,
|
|
useMode: MoveUseMode.FOLLOW_UP,
|
|
});
|
|
});
|
|
|
|
it("should only target ally for Aromatic Mist", async () => {
|
|
game.override.battleStyle("double");
|
|
await game.classicMode.startBattle([SpeciesId.REGIELEKI, SpeciesId.RATTATA]);
|
|
const [leftPlayer, rightPlayer] = game.scene.getPlayerField();
|
|
const [leftOpp, rightOpp] = game.scene.getEnemyField();
|
|
vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(MoveId.AROMATIC_MIST);
|
|
|
|
game.move.select(MoveId.METRONOME, 0);
|
|
await game.phaseInterceptor.to(CommandPhase);
|
|
game.move.select(MoveId.SPLASH, 1);
|
|
await game.toNextTurn();
|
|
|
|
expect(rightPlayer.getStatStage(Stat.SPDEF)).toBe(1);
|
|
expect(leftPlayer.getStatStage(Stat.SPDEF)).toBe(0);
|
|
expect(leftOpp.getStatStage(Stat.SPDEF)).toBe(0);
|
|
expect(rightOpp.getStatStage(Stat.SPDEF)).toBe(0);
|
|
});
|
|
|
|
it("should cause opponent to flee, and not crash for Roar", async () => {
|
|
await game.classicMode.startBattle([SpeciesId.REGIELEKI]);
|
|
vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(MoveId.ROAR);
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
game.move.select(MoveId.METRONOME);
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
const isVisible = enemyPokemon.visible;
|
|
const hasFled = enemyPokemon.switchOutStatus;
|
|
expect(!isVisible && hasFled).toBe(true);
|
|
|
|
await game.phaseInterceptor.to("CommandPhase");
|
|
});
|
|
});
|