Update tests

This commit is contained in:
NightKev 2024-08-27 15:00:42 -07:00
parent b59f437ef8
commit 9e1bcf1dce

View File

@ -2,11 +2,7 @@ import { BattlerIndex } from "#app/battle";
import { allAbilities, PostDefendContactApplyStatusEffectAbAttr } from "#app/data/ability";
import { Abilities } from "#app/enums/abilities";
import { StatusEffect } from "#app/enums/status-effect";
import { CommandPhase } from "#app/phases/command-phase";
import { SelectTargetPhase } from "#app/phases/select-target-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import GameManager from "#app/test/utils/gameManager";
import { getMovePosition } from "#app/test/utils/gameManagerUtils";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import Phaser from "phaser";
@ -41,137 +37,114 @@ describe("Moves - Safeguard", () => {
.ability(Abilities.BALL_FETCH);
});
it("protects from damaging moves with additional effects",
async () => {
await game.startBattle();
const enemy = game.scene.getEnemyPokemon()!;
it("protects from damaging moves with additional effects", async () => {
await game.startBattle();
const enemy = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.NUZZLE));
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.toNextTurn();
game.move.select(Moves.NUZZLE);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.toNextTurn();
expect(enemy.status).toBeUndefined();
}, TIMEOUT
);
expect(enemy.status).toBeUndefined();
}, TIMEOUT);
it("protects from status moves",
async () => {
await game.startBattle();
const enemyPokemon = game.scene.getEnemyPokemon()!;
it("protects from status moves", async () => {
await game.startBattle();
const enemyPokemon = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPORE));
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.toNextTurn();
game.move.select(Moves.SPORE);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.toNextTurn();
expect(enemyPokemon.status).toBeUndefined();
}, TIMEOUT
);
expect(enemyPokemon.status).toBeUndefined();
}, TIMEOUT);
it("protects from confusion",
async () => {
game.override.moveset([Moves.CONFUSE_RAY]);
await game.startBattle();
const enemyPokemon = game.scene.getEnemyPokemon()!;
it("protects from confusion", async () => {
game.override.moveset([Moves.CONFUSE_RAY]);
await game.startBattle();
const enemyPokemon = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.CONFUSE_RAY));
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.toNextTurn();
game.move.select(Moves.CONFUSE_RAY);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.toNextTurn();
expect(enemyPokemon.summonData.tags).toEqual([]);
}, TIMEOUT
);
expect(enemyPokemon.summonData.tags).toEqual([]);
}, TIMEOUT);
it("protects ally from status",
async () => {
game.override.battleType("double");
it("protects ally from status", async () => {
game.override.battleType("double");
await game.startBattle();
await game.startBattle();
game.doAttack(getMovePosition(game.scene, 0, Moves.SPORE));
await game.phaseInterceptor.to(SelectTargetPhase, false);
game.doSelectTarget(BattlerIndex.ENEMY_2);
game.move.select(Moves.SPORE, 0, BattlerIndex.ENEMY_2);
game.move.select(Moves.NUZZLE, 1, BattlerIndex.ENEMY_2);
await game.phaseInterceptor.to(CommandPhase);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2]);
game.doAttack(getMovePosition(game.scene, 1, Moves.NUZZLE));
await game.phaseInterceptor.to(SelectTargetPhase, false);
game.doSelectTarget(BattlerIndex.ENEMY_2);
await game.phaseInterceptor.to("BerryPhase");
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2]);
const enemyPokemon = game.scene.getEnemyField();
await game.phaseInterceptor.to(TurnEndPhase);
expect(enemyPokemon[0].status).toBeUndefined();
expect(enemyPokemon[1].status).toBeUndefined();
}, TIMEOUT);
const enemyPokemon = game.scene.getEnemyField();
it("protects from Yawn", async () => {
await game.startBattle();
const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon[0].status).toBeUndefined();
expect(enemyPokemon[1].status).toBeUndefined();
}, TIMEOUT
);
game.move.select(Moves.YAWN);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.toNextTurn();
it("protects from Yawn",
async () => {
await game.startBattle();
const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon.summonData.tags).toEqual([]);
}, TIMEOUT);
game.doAttack(getMovePosition(game.scene, 0, Moves.YAWN));
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.toNextTurn();
it("doesn't protect from already existing Yawn", async () => {
await game.startBattle();
const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon.summonData.tags).toEqual([]);
}, TIMEOUT
);
game.move.select(Moves.YAWN);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.toNextTurn();
it("doesn't protect from already existing Yawn",
async () => {
await game.startBattle();
const enemyPokemon = game.scene.getEnemyPokemon()!;
game.move.select(Moves.SPLASH);
await game.toNextTurn();
game.doAttack(getMovePosition(game.scene, 0, Moves.YAWN));
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.toNextTurn();
expect(enemyPokemon.status?.effect).toEqual(StatusEffect.SLEEP);
}, TIMEOUT);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
await game.toNextTurn();
it("doesn't protect from self-inflicted via Rest or Flame Orb", async () => {
game.override.enemyHeldItems([{name: "FLAME_ORB"}]);
await game.startBattle();
const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon.status?.effect).toEqual(StatusEffect.SLEEP);
}, TIMEOUT
);
game.move.select(Moves.SPLASH);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.toNextTurn();
it("doesn't protect from self-inflicted via Rest or Flame Orb",
async () => {
game.override.enemyHeldItems([{name: "FLAME_ORB"}]);
await game.startBattle();
const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon.status?.effect).toEqual(StatusEffect.BURN);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.toNextTurn();
game.override.enemyMoveset(Array(4).fill(Moves.REST));
game.move.select(Moves.SPLASH);
await game.toNextTurn();
expect(enemyPokemon.status?.effect).toEqual(StatusEffect.BURN);
expect(enemyPokemon.status?.effect).toEqual(StatusEffect.SLEEP);
}, TIMEOUT);
game.override.enemyMoveset(Array(4).fill(Moves.REST));
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
await game.toNextTurn();
it("protects from ability-inflicted status", async () => {
game.override.ability(Abilities.STATIC);
vi.spyOn(allAbilities[Abilities.STATIC].getAttrs(PostDefendContactApplyStatusEffectAbAttr)[0], "chance", "get").mockReturnValue(100);
await game.startBattle();
const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon.status?.effect).toEqual(StatusEffect.SLEEP);
}, TIMEOUT
);
game.move.select(Moves.SPLASH);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.toNextTurn();
game.override.enemyMoveset(Array(4).fill(Moves.TACKLE));
game.move.select(Moves.SPLASH);
await game.toNextTurn();
it("protects from ability-inflicted status",
async () => {
game.override.ability(Abilities.STATIC);
vi.spyOn(allAbilities[Abilities.STATIC].getAttrs(PostDefendContactApplyStatusEffectAbAttr)[0], "chance", "get").mockReturnValue(100);
await game.startBattle();
const enemyPokemon = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.toNextTurn();
game.override.enemyMoveset(Array(4).fill(Moves.TACKLE));
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
await game.toNextTurn();
expect(enemyPokemon.status).toBeUndefined();
}, TIMEOUT
);
expect(enemyPokemon.status).toBeUndefined();
}, TIMEOUT);
});