Cleaned up safeguard test to not use outdated code; fixed rest of errors

This commit is contained in:
Bertie690 2025-06-03 17:11:32 -04:00
parent a580b07487
commit fa87c43f6d
3 changed files with 13 additions and 18 deletions

View File

@ -64,12 +64,12 @@ describe("Moves - Baton Pass", () => {
// round 1 - ai buffs // round 1 - ai buffs
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.NASTY_PLOT); await game.move.forceEnemyMove(Moves.NASTY_PLOT);
await game.toNextTurn(); await game.toNextTurn();
// round 2 - baton pass // round 2 - baton pass
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.BATON_PASS); await game.move.forceEnemyMove(Moves.BATON_PASS);
await game.phaseInterceptor.to("PostSummonPhase", false); await game.phaseInterceptor.to("PostSummonPhase", false);
// check buffs are still there // check buffs are still there

View File

@ -138,17 +138,17 @@ describe("Moves - Glaive Rush", () => {
player.hp = 1000; player.hp = 1000;
game.move.select(Moves.PROTECT); game.move.select(Moves.PROTECT);
await game.forceEnemyMove(Moves.GLAIVE_RUSH); await game.move.forceEnemyMove(Moves.GLAIVE_RUSH);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
game.move.select(Moves.SHADOW_SNEAK); game.move.select(Moves.SHADOW_SNEAK);
await game.forceEnemyMove(Moves.GLAIVE_RUSH); await game.move.forceEnemyMove(Moves.GLAIVE_RUSH);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
const damagedHP1 = 1000 - enemy.hp; const damagedHP1 = 1000 - enemy.hp;
enemy.hp = 1000; enemy.hp = 1000;
game.move.select(Moves.SHADOW_SNEAK); game.move.select(Moves.SHADOW_SNEAK);
await game.forceEnemyMove(Moves.SPLASH); await game.move.forceEnemyMove(Moves.SPLASH);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
const damagedHP2 = 1000 - enemy.hp; const damagedHP2 = 1000 - enemy.hp;

View File

@ -1,6 +1,5 @@
import { BattlerIndex } from "#app/battle"; import { BattlerIndex } from "#app/battle";
import { PostDefendContactApplyStatusEffectAbAttr } from "#app/data/abilities/ability"; import { PostDefendContactApplyStatusEffectAbAttr } from "#app/data/abilities/ability";
import { allAbilities } from "#app/data/data-lists";
import { Abilities } from "#app/enums/abilities"; import { Abilities } from "#app/enums/abilities";
import { StatusEffect } from "#app/enums/status-effect"; import { StatusEffect } from "#app/enums/status-effect";
import GameManager from "#test/testUtils/gameManager"; import GameManager from "#test/testUtils/gameManager";
@ -113,14 +112,14 @@ describe("Moves - Safeguard", () => {
expect(enemyPokemon.status?.effect).toBe(StatusEffect.SLEEP); expect(enemyPokemon.status?.effect).toBe(StatusEffect.SLEEP);
}); });
it("doesn't protect from self-inflicted via Rest or Flame Orb", async () => { it("doesn't protect from self-inflicted status from Rest or Flame Orb", async () => {
game.override.enemyHeldItems([{ name: "FLAME_ORB" }]).enemyMoveset([Moves.SAFEGUARD, Moves.REST]); game.override.enemyHeldItems([{ name: "FLAME_ORB" }]);
await game.classicMode.startBattle(); await game.classicMode.startBattle();
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
enemyPokemon.hp = 1; enemyPokemon.hp = 1;
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.SAFEGUARD); await game.move.forceEnemyMove(Moves.SAFEGUARD);
await game.toNextTurn(); await game.toNextTurn();
expect(enemyPokemon.status?.effect).toBe(StatusEffect.BURN); expect(enemyPokemon.status?.effect).toBe(StatusEffect.BURN);
@ -128,28 +127,24 @@ describe("Moves - Safeguard", () => {
enemyPokemon.resetStatus(); enemyPokemon.resetStatus();
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.REST); await game.move.forceEnemyMove(Moves.REST);
await game.toNextTurn(); await game.toNextTurn();
expect(enemyPokemon.status?.effect).toBe(StatusEffect.SLEEP); expect(enemyPokemon.status?.effect).toBe(StatusEffect.SLEEP);
}); });
it("protects from ability-inflicted status", async () => { it("protects from ability-inflicted status", async () => {
game.override.ability(Abilities.STATIC).enemyMoveset([Moves.SAFEGUARD, Moves.TACKLE]); game.override.ability(Abilities.STATIC);
vi.spyOn( vi.spyOn(PostDefendContactApplyStatusEffectAbAttr.prototype, "chance", "get").mockReturnValue(100);
allAbilities[Abilities.STATIC].getAttrs(PostDefendContactApplyStatusEffectAbAttr)[0],
"chance",
"get",
).mockReturnValue(100);
await game.classicMode.startBattle(); await game.classicMode.startBattle();
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.SAFEGUARD); await game.move.forceEnemyMove(Moves.SAFEGUARD);
await game.toNextTurn(); await game.toNextTurn();
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.TACKLE); await game.move.forceEnemyMove(Moves.TACKLE);
await game.toNextTurn(); await game.toNextTurn();
expect(enemyPokemon.status).toBeUndefined(); expect(enemyPokemon.status).toBeUndefined();