mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-05-09 18:05:12 +01:00
* Grabbed reverted changes from stuff * Added version migrator for rage fist data + deepMergeSpriteData tests * fixed formattign * Fied a few * Fixed constructor (maybe), moved deepCopy and deepMergeSpriteData to own file `common.ts` is hella bloated so seems legit * Moved empty moveset verification mapping thing to upgrade script bc i wanted to * Fixed tests * test added * Fixed summondata being cleared inside summonPhase, removed `summonDataPrimer` like seriously how come no-one checked this * Fixed test I forgot that we outsped and oneshot * Fixed test * huhjjjjjb * Hopefully fixed bug my sanity and homework are paying the price for this lol * added commented out console.log statement uncomment to see new berry data * Fixed migrate script, re-added deprecated attributes out of necessity * Fixed failing test by not trying to mock rng * Fixed test * Fixed tests * Update ability.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update ability.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update overrides.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update berry-phase.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update encounter-phase.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update game-data.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update move-phase.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Added utility function `randSeedFloat` basically just `Phaser.math.RND.realInRange(0, 1)` * Applied review comments, cleaned up code a bit * Removed unnecessary null checks for turnData and co. I explicitly made them initialized by default for this very reason * Added tests for Last Resort regarding moveHistory * Update pokemon.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update pokemon.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update pokemon.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update pokemon.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update pokemon.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update pokemon.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update pokemon.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update pokemon.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update battle-scene.ts Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> * Update the-winstrate-challenge-encounter.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update pokemon.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update pokemon.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update pokemon.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update ability.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update move.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update move.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update move.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update battle-anims.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update pokemon.ts comments * Fixed a few outstanding issues with documentation * Updated switch summon phase comment * Re-added BattleSummonData as TempSummonData * Hppefully fixed -1 sprite scale glitch * Fixed comment * Reveted `pokemon-forms.ts` * Fuxed constructor * fixed -1 bug * Revert "Added utility function `randSeedFloat`" This reverts commit 4c3447c851731c989fc591feea0094b6bbde7fd2. --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com>
134 lines
4.8 KiB
TypeScript
134 lines
4.8 KiB
TypeScript
import { BattlerTagType } from "#enums/battler-tag-type";
|
|
import { StatusEffect } from "#enums/status-effect";
|
|
import { MoveResult } from "#app/field/pokemon";
|
|
import { Abilities } from "#enums/abilities";
|
|
import { Moves } from "#enums/moves";
|
|
import { Species } from "#enums/species";
|
|
import GameManager from "#test/testUtils/gameManager";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, it, expect } from "vitest";
|
|
import { WeatherType } from "#enums/weather-type";
|
|
|
|
describe("Moves - Dive", () => {
|
|
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(Moves.DIVE)
|
|
.battleStyle("single")
|
|
.startingLevel(100)
|
|
.enemySpecies(Species.SNORLAX)
|
|
.enemyLevel(100)
|
|
.enemyAbility(Abilities.BALL_FETCH)
|
|
.enemyMoveset(Moves.TACKLE);
|
|
});
|
|
|
|
it("should make the user semi-invulnerable, then attack over 2 turns", async () => {
|
|
await game.classicMode.startBattle([Species.MAGIKARP]);
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
game.move.select(Moves.DIVE);
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
expect(playerPokemon.getTag(BattlerTagType.UNDERWATER)).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(Moves.DIVE);
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
expect(playerPokemon.getTag(BattlerTagType.UNDERWATER)).toBeUndefined();
|
|
expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp());
|
|
expect(playerPokemon.getMoveHistory()).toHaveLength(2);
|
|
|
|
const playerDive = playerPokemon.getMoveset().find(mv => mv && mv.moveId === Moves.DIVE);
|
|
expect(playerDive?.ppUsed).toBe(1);
|
|
});
|
|
|
|
it("should not allow the user to evade attacks from Pokemon with No Guard", async () => {
|
|
game.override.enemyAbility(Abilities.NO_GUARD);
|
|
|
|
await game.classicMode.startBattle([Species.MAGIKARP]);
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
game.move.select(Moves.DIVE);
|
|
|
|
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(Abilities.NO_GUARD).enemyMoveset(Moves.SPORE);
|
|
|
|
await game.classicMode.startBattle([Species.MAGIKARP]);
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
game.move.select(Moves.DIVE);
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
expect(playerPokemon.getTag(BattlerTagType.UNDERWATER)).toBeUndefined();
|
|
expect(playerPokemon.status?.effect).toBe(StatusEffect.SLEEP);
|
|
|
|
const playerDive = playerPokemon.getMoveset().find(mv => mv && mv.moveId === Moves.DIVE);
|
|
expect(playerDive?.ppUsed).toBe(0);
|
|
});
|
|
|
|
it("should trigger on-contact post-defend ability effects", async () => {
|
|
game.override.enemyAbility(Abilities.ROUGH_SKIN).enemyMoveset(Moves.SPLASH);
|
|
|
|
await game.classicMode.startBattle([Species.MAGIKARP]);
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
game.move.select(Moves.DIVE);
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
await game.phaseInterceptor.to("MoveEndPhase");
|
|
expect(playerPokemon.hp).toBeLessThan(playerPokemon.getMaxHp());
|
|
expect(enemyPokemon.waveData.abilitiesApplied).toContain(Abilities.ROUGH_SKIN);
|
|
});
|
|
|
|
it("should cancel attack after Harsh Sunlight is set", async () => {
|
|
game.override.enemyMoveset(Moves.SPLASH);
|
|
|
|
await game.classicMode.startBattle([Species.MAGIKARP]);
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
game.move.select(Moves.DIVE);
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
await game.phaseInterceptor.to("TurnStartPhase", false);
|
|
game.scene.arena.trySetWeather(WeatherType.HARSH_SUN);
|
|
|
|
await game.phaseInterceptor.to("MoveEndPhase");
|
|
expect(playerPokemon.getLastXMoves(1)[0].result).toBe(MoveResult.FAIL);
|
|
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
|
|
expect(playerPokemon.getTag(BattlerTagType.UNDERWATER)).toBeUndefined();
|
|
|
|
const playerDive = playerPokemon.getMoveset().find(mv => mv && mv.moveId === Moves.DIVE);
|
|
expect(playerDive?.ppUsed).toBe(1);
|
|
});
|
|
});
|