mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-12-15 14:25:32 +01:00
* Added mock console and fixed up many many things * Cleaned up handling of colors and such * Added minor comment * Fix Focus Punch test * Fix typo * Remove redundant comment * Update vitest.setup.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Added color map inside new folder * Made constants not object bc i was told to * Update src/constants/colors.ts * Removed all moves init check * Removed import * Fixed up some stuff + added aquamarine color to settings helper * Added logging for test end * Removed intentionally failing test * Fixed console log to use inheritance to not override vitest's wrapping * Added a custom Vitest reporter to not log the test name every 2 lines * Moved coloration to a hook to prevent misplacing things * Fixed import issue by copypasting vitest soure * Removed intentionally failing test look i need to check that `test:silent` works on github ok * Added REUSE annotations to copied parts of source * Fixed import issue --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
133 lines
4.5 KiB
TypeScript
133 lines
4.5 KiB
TypeScript
import { AbilityId } from "#enums/ability-id";
|
|
import { MoveId } from "#enums/move-id";
|
|
import { SpeciesId } from "#enums/species-id";
|
|
import { BerryPhase } from "#phases/berry-phase";
|
|
import { MessagePhase } from "#phases/message-phase";
|
|
import { MoveHeaderPhase } from "#phases/move-header-phase";
|
|
import { SwitchSummonPhase } from "#phases/switch-summon-phase";
|
|
import { TurnStartPhase } from "#phases/turn-start-phase";
|
|
import { GameManager } from "#test/test-utils/game-manager";
|
|
import i18next from "i18next";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
|
|
describe("Moves - Focus Punch", () => {
|
|
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("single")
|
|
.ability(AbilityId.UNNERVE)
|
|
.moveset([MoveId.FOCUS_PUNCH])
|
|
.enemySpecies(SpeciesId.GROUDON)
|
|
.enemyAbility(AbilityId.INSOMNIA)
|
|
.enemyMoveset(MoveId.SPLASH)
|
|
.startingLevel(100)
|
|
.enemyLevel(100);
|
|
});
|
|
|
|
it("should deal damage at the end of turn if uninterrupted", async () => {
|
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
|
|
|
const leadPokemon = game.field.getPlayerPokemon();
|
|
const enemyPokemon = game.field.getEnemyPokemon();
|
|
|
|
const enemyStartingHp = enemyPokemon.hp;
|
|
|
|
game.move.select(MoveId.FOCUS_PUNCH);
|
|
|
|
await game.phaseInterceptor.to(MessagePhase);
|
|
|
|
expect(enemyPokemon.hp).toBe(enemyStartingHp);
|
|
expect(leadPokemon.getMoveHistory().length).toBe(0);
|
|
|
|
await game.phaseInterceptor.to(BerryPhase, false);
|
|
|
|
expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp);
|
|
expect(leadPokemon.getMoveHistory().length).toBe(1);
|
|
expect(leadPokemon.turnData.totalDamageDealt).toBe(enemyStartingHp - enemyPokemon.hp);
|
|
});
|
|
|
|
it("should fail if the user is hit", async () => {
|
|
game.override.enemyMoveset([MoveId.TACKLE]);
|
|
|
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
|
|
|
const leadPokemon = game.field.getPlayerPokemon();
|
|
const enemyPokemon = game.field.getEnemyPokemon();
|
|
|
|
const enemyStartingHp = enemyPokemon.hp;
|
|
|
|
game.move.select(MoveId.FOCUS_PUNCH);
|
|
|
|
await game.phaseInterceptor.to(MessagePhase);
|
|
|
|
expect(enemyPokemon.hp).toBe(enemyStartingHp);
|
|
expect(leadPokemon.getMoveHistory().length).toBe(0);
|
|
|
|
await game.phaseInterceptor.to(BerryPhase, false);
|
|
|
|
expect(enemyPokemon.hp).toBe(enemyStartingHp);
|
|
expect(leadPokemon.getMoveHistory().length).toBe(1);
|
|
expect(leadPokemon.turnData.totalDamageDealt).toBe(0);
|
|
});
|
|
|
|
it("should be cancelled if the user falls asleep mid-turn", async () => {
|
|
game.override.enemyMoveset([MoveId.SPORE]);
|
|
|
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
|
|
|
const leadPokemon = game.field.getPlayerPokemon();
|
|
const enemyPokemon = game.field.getEnemyPokemon();
|
|
|
|
game.move.select(MoveId.FOCUS_PUNCH);
|
|
|
|
await game.phaseInterceptor.to(MessagePhase); // Header message
|
|
|
|
expect(leadPokemon.getMoveHistory().length).toBe(0);
|
|
|
|
await game.phaseInterceptor.to(BerryPhase, false);
|
|
|
|
expect(leadPokemon.getMoveHistory().length).toBe(1);
|
|
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
|
|
});
|
|
|
|
it("should not queue its pre-move message before an enemy switches", async () => {
|
|
/** Guarantee a Trainer battle with multiple enemy Pokemon */
|
|
game.override.startingWave(25);
|
|
|
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
|
|
|
game.forceEnemyToSwitch();
|
|
game.move.select(MoveId.FOCUS_PUNCH);
|
|
|
|
await game.phaseInterceptor.to(TurnStartPhase);
|
|
|
|
expect(game.scene.phaseManager.getCurrentPhase() instanceof SwitchSummonPhase).toBeTruthy();
|
|
expect(game.scene.phaseManager.phaseQueue.find(phase => phase instanceof MoveHeaderPhase)).toBeDefined();
|
|
});
|
|
it("should replace the 'but it failed' text when the user gets hit", async () => {
|
|
game.override.enemyMoveset([MoveId.TACKLE]);
|
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
|
|
|
game.move.select(MoveId.FOCUS_PUNCH);
|
|
await game.phaseInterceptor.to("MoveEndPhase", true);
|
|
await game.phaseInterceptor.to("MessagePhase", false);
|
|
await game.phaseInterceptor.to("MoveEndPhase", true);
|
|
expect(game.textInterceptor.logs).toContain(i18next.t("moveTriggers:lostFocus", { pokemonName: "Charizard" }));
|
|
expect(game.textInterceptor.logs).not.toContain(i18next.t("battle:attackFailed"));
|
|
});
|
|
});
|