mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-09 17:09:26 +02:00
* Protect rng now resets on new waves and fixed to look at all turns in the same wave. * Added per-wave move history object to fix issues @Jimmybald1 I added a commented out `console.log` in the protect code (L5797) for you to use for testing * Added many tests * Wave move history has to be looped in reverse * Update src/data/moves/move.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update src/data/moves/move.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * comments * Fixed forceEnemyMove references after merge * Removed console log Co-authored-by: Amani H. <109637146+xsn34kzx@users.noreply.github.com> * Fixed test message Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> * Apply Biome * Fix merge issues * Fix Crafty Shield test * Remove protect chance reset on wave change * Fix merge issue --------- Co-authored-by: Jimmybald1 <147992650+IBBCalc@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: Amani H. <109637146+xsn34kzx@users.noreply.github.com> Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com>
85 lines
2.8 KiB
TypeScript
85 lines
2.8 KiB
TypeScript
import { AbilityId } from "#enums/ability-id";
|
|
import { HitResult } from "#enums/hit-result";
|
|
import { MoveId } from "#enums/move-id";
|
|
import { SpeciesId } from "#enums/species-id";
|
|
import { GameManager } from "#test/test-utils/game-manager";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
describe("Moves - Endure", () => {
|
|
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.THUNDER, MoveId.BULLET_SEED, MoveId.SHEER_COLD])
|
|
.ability(AbilityId.SKILL_LINK)
|
|
.startingLevel(100)
|
|
.battleStyle("single")
|
|
.criticalHits(false)
|
|
.enemySpecies(SpeciesId.MAGIKARP)
|
|
.enemyAbility(AbilityId.NO_GUARD)
|
|
.enemyMoveset(MoveId.ENDURE);
|
|
});
|
|
|
|
it("should let the pokemon survive with 1 HP from attacks", async () => {
|
|
await game.classicMode.startBattle([SpeciesId.ARCEUS]);
|
|
|
|
game.move.select(MoveId.THUNDER);
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
expect(game.field.getEnemyPokemon().hp).toBe(1);
|
|
});
|
|
|
|
it("should let the pokemon survive with 1 HP from multi-strike moves", async () => {
|
|
await game.classicMode.startBattle([SpeciesId.ARCEUS]);
|
|
|
|
game.move.select(MoveId.BULLET_SEED);
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
expect(game.field.getEnemyPokemon().hp).toBe(1);
|
|
});
|
|
|
|
it("should let the pokemon survive against OHKO moves", async () => {
|
|
await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
|
|
const enemy = game.field.getEnemyPokemon();
|
|
|
|
game.move.select(MoveId.SHEER_COLD);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
expect(enemy.hp).toBe(1);
|
|
});
|
|
|
|
// comprehensive indirect damage test copied from Reviver Seed test
|
|
it.each([
|
|
{ moveType: "Damaging Move Chip", move: MoveId.SALT_CURE },
|
|
{ moveType: "Status Move Chip", move: MoveId.LEECH_SEED },
|
|
{ moveType: "Partial Trapping move", move: MoveId.WHIRLPOOL },
|
|
{ moveType: "Status Effect", move: MoveId.TOXIC },
|
|
{ moveType: "Weather", move: MoveId.SANDSTORM },
|
|
])("should not prevent fainting from $moveType Damage", async ({ move }) => {
|
|
game.override.moveset(move).enemyLevel(100);
|
|
await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.FEEBAS]);
|
|
const enemy = game.field.getEnemyPokemon();
|
|
enemy.hp = 2;
|
|
// force attack to do 1 dmg (for salt cure)
|
|
vi.spyOn(enemy, "getAttackDamage").mockReturnValue({ cancelled: false, result: HitResult.EFFECTIVE, damage: 1 });
|
|
|
|
game.move.select(move);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
expect(enemy.isFainted()).toBe(true);
|
|
});
|
|
});
|