mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 09:02:47 +02:00
* Move game-mode to its own file Reduces circular imports to 325 * Move battler-index to own file Reduces circular deps to 314 * Move trainer-variant to own file Reduces circ deps to 313 * Move enums in pokemon to their own file * Move arena-tag-type to its own file * Move pokemon-moves to its own file * Move command to own file * Move learnMoveType to own file * Move form change item to own file * Move battlerTagLapseType to own file * Move anim enums to own shared file * Move enums out of challenges * Move species form change triggers to own file Reduces circ imports to 291 * Update test importing pokemon move * Replace move attribute imports with string names * Untangle circular deps from game data * Fix missing string call in switch summon phase * Apply kev's suggestions from code review Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Ensure ChargeMove's is method calls super * Use InstanceType for proper narrowing * Apply kev's suggestions from code review Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
121 lines
4.3 KiB
TypeScript
121 lines
4.3 KiB
TypeScript
import { BattlerTagType } from "#enums/battler-tag-type";
|
|
import { StatusEffect } from "#enums/status-effect";
|
|
import { MoveResult } from "#enums/move-result";
|
|
import { AbilityId } from "#enums/ability-id";
|
|
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";
|
|
import { BattlerIndex } from "#enums/battler-index";
|
|
import { allMoves } from "#app/data/data-lists";
|
|
|
|
describe("Moves - Fly", () => {
|
|
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
|
|
.moveset(MoveId.FLY)
|
|
.battleStyle("single")
|
|
.startingLevel(100)
|
|
.enemySpecies(SpeciesId.SNORLAX)
|
|
.enemyLevel(100)
|
|
.enemyAbility(AbilityId.BALL_FETCH)
|
|
.enemyMoveset(MoveId.TACKLE);
|
|
|
|
vi.spyOn(allMoves[MoveId.FLY], "accuracy", "get").mockReturnValue(100);
|
|
});
|
|
|
|
it("should make the user semi-invulnerable, then attack over 2 turns", async () => {
|
|
await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
game.move.select(MoveId.FLY);
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
expect(playerPokemon.getTag(BattlerTagType.FLYING)).toBeDefined();
|
|
expect(enemyPokemon.getLastXMoves(1)[0].result).toBe(MoveResult.MISS);
|
|
expect(playerPokemon.hp).toBe(playerPokemon.getMaxHp());
|
|
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
|
|
expect(playerPokemon.getMoveQueue()[0].move).toBe(MoveId.FLY);
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
expect(playerPokemon.getTag(BattlerTagType.FLYING)).toBeUndefined();
|
|
expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp());
|
|
expect(playerPokemon.getMoveHistory()).toHaveLength(2);
|
|
|
|
const playerFly = playerPokemon.getMoveset().find(mv => mv && mv.moveId === MoveId.FLY);
|
|
expect(playerFly?.ppUsed).toBe(1);
|
|
});
|
|
|
|
it("should not allow the user to evade attacks from Pokemon with No Guard", async () => {
|
|
game.override.enemyAbility(AbilityId.NO_GUARD);
|
|
|
|
await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
game.move.select(MoveId.FLY);
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
expect(playerPokemon.hp).toBeLessThan(playerPokemon.getMaxHp());
|
|
expect(enemyPokemon.getLastXMoves(1)[0].result).toBe(MoveResult.SUCCESS);
|
|
});
|
|
|
|
it("should not expend PP when the attack phase is cancelled", async () => {
|
|
game.override.enemyAbility(AbilityId.NO_GUARD).enemyMoveset(MoveId.SPORE);
|
|
|
|
await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
game.move.select(MoveId.FLY);
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
expect(playerPokemon.getTag(BattlerTagType.FLYING)).toBeUndefined();
|
|
expect(playerPokemon.status?.effect).toBe(StatusEffect.SLEEP);
|
|
|
|
const playerFly = playerPokemon.getMoveset().find(mv => mv && mv.moveId === MoveId.FLY);
|
|
expect(playerFly?.ppUsed).toBe(0);
|
|
});
|
|
|
|
it("should be cancelled when another Pokemon uses Gravity", async () => {
|
|
game.override.enemyMoveset([MoveId.SPLASH, MoveId.GRAVITY]);
|
|
|
|
await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
game.move.select(MoveId.FLY);
|
|
|
|
await game.move.selectEnemyMove(MoveId.SPLASH);
|
|
|
|
await game.toNextTurn();
|
|
await game.move.selectEnemyMove(MoveId.GRAVITY);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
expect(playerPokemon.getLastXMoves(1)[0].result).toBe(MoveResult.FAIL);
|
|
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
|
|
|
|
const playerFly = playerPokemon.getMoveset().find(mv => mv && mv.moveId === MoveId.FLY);
|
|
expect(playerFly?.ppUsed).toBe(0);
|
|
});
|
|
});
|