mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-30 21:42:20 +02:00
* [WIP] Refactor ability attribute apply args * [WIP] update ability signatures * Update callsites in pokemon.ts * Update callsites in moves.ts * Update abattr callsites in move-phase * Update abattr callsites in battler-tags Also removed stat drop ability application from cancelling ME stat boost effects * format with biome and remove cancelled from weather lapse * Update abattr callsites in MEP * Update callsites in turn-start-phase * Update abAttr callsites in misc phases * Remove latent test functionality * update ability attribute callsite in shield dust test * update abattr callsite in winstrate challenge encounter * Fix some tests to mock proper methods * Remove improper condition in mimicry's ability application * Fix improper simulated check in moody's apply method * Pass source to postApplyDamage in pokemon.ts * [wip] fix cud chew tests * Make cud chew consumption not subclass postTurnAbAttr * Fix regression in flower veil * Update trySetStatus test in pokemon to respect new return value for undefined * Remove empty, unused file * Fix blockCrit method broken in merge * Fix unnecessary attr type cast in move phase * Address typing issue in safeguard test * Improve documentation and get rid of ts-expect-error directive * Minor comment/TSDoc updates and fixes * Apply suggestions from code review Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Apply suggestions from code review --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
158 lines
4.9 KiB
TypeScript
158 lines
4.9 KiB
TypeScript
import { BattlerIndex } from "#enums/battler-index";
|
|
import { allAbilities } from "#app/data/data-lists";
|
|
import { StatusEffect } from "#app/enums/status-effect";
|
|
import GameManager from "#test/testUtils/gameManager";
|
|
import { MoveId } from "#enums/move-id";
|
|
import { SpeciesId } from "#enums/species-id";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { AbilityId } from "#enums/ability-id";
|
|
|
|
describe("Moves - Safeguard", () => {
|
|
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")
|
|
.enemySpecies(SpeciesId.DRATINI)
|
|
.enemyMoveset([MoveId.SAFEGUARD])
|
|
.enemyAbility(AbilityId.BALL_FETCH)
|
|
.enemyLevel(5)
|
|
.starterSpecies(SpeciesId.DRATINI)
|
|
.moveset([MoveId.NUZZLE, MoveId.SPORE, MoveId.YAWN, MoveId.SPLASH])
|
|
.ability(AbilityId.UNNERVE); // Stop wild Pokemon from potentially eating Lum Berry
|
|
});
|
|
|
|
it("protects from damaging moves with additional effects", async () => {
|
|
await game.classicMode.startBattle();
|
|
const enemy = game.scene.getEnemyPokemon()!;
|
|
|
|
game.move.select(MoveId.NUZZLE);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
await game.toNextTurn();
|
|
|
|
expect(enemy.status).toBeUndefined();
|
|
});
|
|
|
|
it("protects from status moves", async () => {
|
|
await game.classicMode.startBattle();
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
game.move.select(MoveId.SPORE);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
await game.toNextTurn();
|
|
|
|
expect(enemyPokemon.status).toBeUndefined();
|
|
});
|
|
|
|
it("protects from confusion", async () => {
|
|
game.override.moveset([MoveId.CONFUSE_RAY]);
|
|
await game.classicMode.startBattle();
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
game.move.select(MoveId.CONFUSE_RAY);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
await game.toNextTurn();
|
|
|
|
expect(enemyPokemon.summonData.tags).toEqual([]);
|
|
});
|
|
|
|
it("protects ally from status", async () => {
|
|
game.override.battleStyle("double");
|
|
|
|
await game.classicMode.startBattle();
|
|
|
|
game.move.select(MoveId.SPORE, 0, BattlerIndex.ENEMY_2);
|
|
game.move.select(MoveId.NUZZLE, 1, BattlerIndex.ENEMY_2);
|
|
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2]);
|
|
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
const enemyPokemon = game.scene.getEnemyField();
|
|
|
|
expect(enemyPokemon[0].status).toBeUndefined();
|
|
expect(enemyPokemon[1].status).toBeUndefined();
|
|
});
|
|
|
|
it("protects from Yawn", async () => {
|
|
await game.classicMode.startBattle();
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
game.move.select(MoveId.YAWN);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
await game.toNextTurn();
|
|
|
|
expect(enemyPokemon.summonData.tags).toEqual([]);
|
|
});
|
|
|
|
it("doesn't protect from already existing Yawn", async () => {
|
|
await game.classicMode.startBattle();
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
game.move.select(MoveId.YAWN);
|
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
await game.toNextTurn();
|
|
|
|
game.move.select(MoveId.SPLASH);
|
|
await game.toNextTurn();
|
|
|
|
expect(enemyPokemon.status?.effect).toBe(StatusEffect.SLEEP);
|
|
});
|
|
|
|
it("doesn't protect from self-inflicted status from Rest or Flame Orb", async () => {
|
|
game.override.enemyHeldItems([{ name: "FLAME_ORB" }]);
|
|
await game.classicMode.startBattle();
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
enemyPokemon.hp = 1;
|
|
|
|
game.move.select(MoveId.SPLASH);
|
|
await game.move.forceEnemyMove(MoveId.SAFEGUARD);
|
|
await game.toNextTurn();
|
|
|
|
expect(enemyPokemon.status?.effect).toBe(StatusEffect.BURN);
|
|
|
|
enemyPokemon.resetStatus();
|
|
|
|
game.move.select(MoveId.SPLASH);
|
|
await game.move.forceEnemyMove(MoveId.REST);
|
|
await game.toNextTurn();
|
|
|
|
expect(enemyPokemon.status?.effect).toBe(StatusEffect.SLEEP);
|
|
});
|
|
|
|
it("protects from ability-inflicted status", async () => {
|
|
await game.classicMode.startBattle();
|
|
|
|
const player = game.field.getPlayerPokemon();
|
|
game.field.mockAbility(player, AbilityId.STATIC);
|
|
vi.spyOn(
|
|
allAbilities[AbilityId.STATIC].getAttrs("PostDefendContactApplyStatusEffectAbAttr")[0],
|
|
"canApply",
|
|
).mockReturnValue(true);
|
|
|
|
game.move.select(MoveId.SPLASH);
|
|
await game.move.forceEnemyMove(MoveId.SAFEGUARD);
|
|
await game.toNextTurn();
|
|
|
|
game.move.select(MoveId.SPLASH);
|
|
await game.move.forceEnemyMove(MoveId.TACKLE);
|
|
await game.toNextTurn();
|
|
|
|
const enemyPokemon = game.field.getEnemyPokemon();
|
|
expect(enemyPokemon.status).toBeUndefined();
|
|
});
|
|
});
|