diff --git a/src/test/abilities/dry_skin.test.ts b/src/test/abilities/dry_skin.test.ts index b337e4d96f7..59a3cb2bb19 100644 --- a/src/test/abilities/dry_skin.test.ts +++ b/src/test/abilities/dry_skin.test.ts @@ -1,5 +1,4 @@ import { Species } from "#app/enums/species"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import GameManager from "#test/utils/gameManager"; @@ -23,63 +22,56 @@ describe("Abilities - Dry Skin", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.battleType("single"); - game.override.disableCrits(); - game.override.enemyAbility(Abilities.DRY_SKIN); - game.override.enemyMoveset(SPLASH_ONLY); - game.override.enemySpecies(Species.CHARMANDER); - game.override.ability(Abilities.UNNERVE); - game.override.starterSpecies(Species.CHANDELURE); + game.override + .battleType("single") + .disableCrits() + .enemyAbility(Abilities.DRY_SKIN) + .enemyMoveset(SPLASH_ONLY) + .enemySpecies(Species.CHARMANDER) + .ability(Abilities.BALL_FETCH) + .moveset([Moves.SUNNY_DAY, Moves.RAIN_DANCE, Moves.SPLASH, Moves.WATER_GUN]) + .starterSpecies(Species.CHANDELURE); }); it("during sunlight, lose 1/8 of maximum health at the end of each turn", async () => { - game.override.moveset([Moves.SUNNY_DAY, Moves.SPLASH]); - - await game.startBattle(); + await game.classicMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; - expect(enemy).not.toBe(undefined); // first turn - let previousEnemyHp = enemy.hp; game.move.select(Moves.SUNNY_DAY); - await game.phaseInterceptor.to(TurnEndPhase); - expect(enemy.hp).toBeLessThan(previousEnemyHp); + await game.phaseInterceptor.to("TurnEndPhase"); + expect(enemy.hp).toBeLessThan(enemy.getMaxHp()); // second turn - previousEnemyHp = enemy.hp; + enemy.hp = enemy.getMaxHp(); game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); - expect(enemy.hp).toBeLessThan(previousEnemyHp); + await game.phaseInterceptor.to("TurnEndPhase"); + expect(enemy.hp).toBeLessThan(enemy.getMaxHp()); }); it("during rain, gain 1/8 of maximum health at the end of each turn", async () => { - game.override.moveset([Moves.RAIN_DANCE, Moves.SPLASH]); - - await game.startBattle(); + await game.classicMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; - expect(enemy).not.toBe(undefined); enemy.hp = 1; // first turn - let previousEnemyHp = enemy.hp; game.move.select(Moves.RAIN_DANCE); - await game.phaseInterceptor.to(TurnEndPhase); - expect(enemy.hp).toBeGreaterThan(previousEnemyHp); + await game.phaseInterceptor.to("TurnEndPhase"); + expect(enemy.hp).toBeGreaterThan(1); // second turn - previousEnemyHp = enemy.hp; + enemy.hp = 1; game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); - expect(enemy.hp).toBeGreaterThan(previousEnemyHp); + await game.phaseInterceptor.to("TurnEndPhase"); + expect(enemy.hp).toBeGreaterThan(1); }); it("opposing fire attacks do 25% more damage", async () => { game.override.moveset([Moves.FLAMETHROWER]); - - await game.startBattle(); + await game.classicMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; const initialHP = 1000; @@ -87,72 +79,65 @@ describe("Abilities - Dry Skin", () => { // first turn game.move.select(Moves.FLAMETHROWER); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const fireDamageTakenWithDrySkin = initialHP - enemy.hp; - expect(enemy.hp > 0); enemy.hp = initialHP; game.override.enemyAbility(Abilities.NONE); // second turn game.move.select(Moves.FLAMETHROWER); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const fireDamageTakenWithoutDrySkin = initialHP - enemy.hp; expect(fireDamageTakenWithDrySkin).toBeGreaterThan(fireDamageTakenWithoutDrySkin); }); it("opposing water attacks heal 1/4 of maximum health and deal no damage", async () => { - game.override.moveset([Moves.WATER_GUN]); - - await game.startBattle(); + await game.classicMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; - expect(enemy).not.toBe(undefined); enemy.hp = 1; game.move.select(Moves.WATER_GUN); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemy.hp).toBeGreaterThan(1); }); it("opposing water attacks do not heal if they were protected from", async () => { - game.override.moveset([Moves.WATER_GUN]); + game.override.enemyMoveset([Moves.PROTECT]); - await game.startBattle(); + await game.classicMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; - expect(enemy).not.toBe(undefined); enemy.hp = 1; - game.override.enemyMoveset([Moves.PROTECT, Moves.PROTECT, Moves.PROTECT, Moves.PROTECT]); game.move.select(Moves.WATER_GUN); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemy.hp).toBe(1); }); it("multi-strike water attacks only heal once", async () => { game.override.moveset([Moves.WATER_GUN, Moves.WATER_SHURIKEN]); - await game.startBattle(); + await game.classicMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; - expect(enemy).not.toBe(undefined); enemy.hp = 1; // first turn game.move.select(Moves.WATER_SHURIKEN); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const healthGainedFromWaterShuriken = enemy.hp - 1; enemy.hp = 1; // second turn game.move.select(Moves.WATER_GUN); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const healthGainedFromWaterGun = enemy.hp - 1; expect(healthGainedFromWaterShuriken).toBe(healthGainedFromWaterGun); diff --git a/src/test/moves/safeguard.test.ts b/src/test/moves/safeguard.test.ts index 62f6aed3b0e..0762325a4cd 100644 --- a/src/test/moves/safeguard.test.ts +++ b/src/test/moves/safeguard.test.ts @@ -38,7 +38,7 @@ describe("Moves - Safeguard", () => { }); it("protects from damaging moves with additional effects", async () => { - await game.startBattle(); + await game.classicMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; game.move.select(Moves.NUZZLE); @@ -49,7 +49,7 @@ describe("Moves - Safeguard", () => { }, TIMEOUT); it("protects from status moves", async () => { - await game.startBattle(); + await game.classicMode.startBattle(); const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.select(Moves.SPORE); @@ -61,7 +61,7 @@ describe("Moves - Safeguard", () => { it("protects from confusion", async () => { game.override.moveset([Moves.CONFUSE_RAY]); - await game.startBattle(); + await game.classicMode.startBattle(); const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.select(Moves.CONFUSE_RAY); @@ -74,7 +74,7 @@ describe("Moves - Safeguard", () => { it("protects ally from status", async () => { game.override.battleType("double"); - await game.startBattle(); + await game.classicMode.startBattle(); game.move.select(Moves.SPORE, 0, BattlerIndex.ENEMY_2); game.move.select(Moves.NUZZLE, 1, BattlerIndex.ENEMY_2); @@ -90,7 +90,7 @@ describe("Moves - Safeguard", () => { }, TIMEOUT); it("protects from Yawn", async () => { - await game.startBattle(); + await game.classicMode.startBattle(); const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.select(Moves.YAWN); @@ -101,7 +101,7 @@ describe("Moves - Safeguard", () => { }, TIMEOUT); it("doesn't protect from already existing Yawn", async () => { - await game.startBattle(); + await game.classicMode.startBattle(); const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.select(Moves.YAWN); @@ -116,7 +116,7 @@ describe("Moves - Safeguard", () => { it("doesn't protect from self-inflicted via Rest or Flame Orb", async () => { game.override.enemyHeldItems([{name: "FLAME_ORB"}]); - await game.startBattle(); + await game.classicMode.startBattle(); const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.select(Moves.SPLASH); @@ -126,7 +126,11 @@ describe("Moves - Safeguard", () => { expect(enemyPokemon.status?.effect).toEqual(StatusEffect.BURN); game.override.enemyMoveset([Moves.REST]); + // Force the moveset to update mid-battle + // TODO: Remove after enemy AI rework is in + enemyPokemon.getMoveset(); game.move.select(Moves.SPLASH); + enemyPokemon.damageAndUpdate(1); await game.toNextTurn(); expect(enemyPokemon.status?.effect).toEqual(StatusEffect.SLEEP); @@ -135,7 +139,7 @@ describe("Moves - Safeguard", () => { 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(); + await game.classicMode.startBattle(); const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.select(Moves.SPLASH);