From 1965f2b147e292e73785d010b51eca8de3a21f89 Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Thu, 11 Jul 2024 21:28:13 -0700 Subject: [PATCH] [Test] Update tests to enable no-crits override (#2971) * Update tests to enable no-crits override * Rename variable maxHP to initialHP --- src/test/abilities/dry_skin.test.ts | 21 ++++++++++----------- src/test/abilities/parental_bond.test.ts | 3 +-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/test/abilities/dry_skin.test.ts b/src/test/abilities/dry_skin.test.ts index bfb8f45a11f..29e7057bd84 100644 --- a/src/test/abilities/dry_skin.test.ts +++ b/src/test/abilities/dry_skin.test.ts @@ -25,6 +25,7 @@ describe("Abilities - Dry Skin", () => { beforeEach(() => { game = new GameManager(phaserGame); vi.spyOn(overrides, "SINGLE_BATTLE_OVERRIDE", "get").mockReturnValue(true); + vi.spyOn(overrides, "NEVER_CRIT_OVERRIDE", "get").mockReturnValue(true); vi.spyOn(overrides, "OPP_ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.DRY_SKIN); vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]); vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.CHARMANDER); @@ -77,30 +78,28 @@ describe("Abilities - Dry Skin", () => { }); it("opposing fire attacks do 25% more damage", async () => { - vi.spyOn(overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.EMBER]); - - // ensure the enemy doesn't die to this - vi.spyOn(overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(30); + vi.spyOn(overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.FLAMETHROWER]); await game.startBattle(); const enemy = game.scene.getEnemyPokemon(); - expect(enemy).not.toBe(undefined); + expect(enemy).toBeDefined(); + const initialHP = 1000; + enemy.hp = initialHP; // first turn - vi.spyOn(game.scene, "randBattleSeedInt").mockReturnValue(0); // this makes moves always deal 85% damage - game.doAttack(getMovePosition(game.scene, 0, Moves.EMBER)); + game.doAttack(getMovePosition(game.scene, 0, Moves.FLAMETHROWER)); await game.phaseInterceptor.to(TurnEndPhase); - const fireDamageTakenWithDrySkin = enemy.getMaxHp() - enemy.hp; + const fireDamageTakenWithDrySkin = initialHP - enemy.hp; expect(enemy.hp > 0); - enemy.hp = enemy.getMaxHp(); + enemy.hp = initialHP; vi.spyOn(overrides, "OPP_ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.NONE); // second turn - game.doAttack(getMovePosition(game.scene, 0, Moves.EMBER)); + game.doAttack(getMovePosition(game.scene, 0, Moves.FLAMETHROWER)); await game.phaseInterceptor.to(TurnEndPhase); - const fireDamageTakenWithoutDrySkin = enemy.getMaxHp() - enemy.hp; + const fireDamageTakenWithoutDrySkin = initialHP - enemy.hp; expect(fireDamageTakenWithDrySkin).toBeGreaterThan(fireDamageTakenWithoutDrySkin); }); diff --git a/src/test/abilities/parental_bond.test.ts b/src/test/abilities/parental_bond.test.ts index 77877ef529a..cfa6d94182f 100644 --- a/src/test/abilities/parental_bond.test.ts +++ b/src/test/abilities/parental_bond.test.ts @@ -31,6 +31,7 @@ describe("Abilities - Parental Bond", () => { beforeEach(() => { game = new GameManager(phaserGame); vi.spyOn(Overrides, "SINGLE_BATTLE_OVERRIDE", "get").mockReturnValue(true); + vi.spyOn(Overrides, "NEVER_CRIT_OVERRIDE", "get").mockReturnValue(true); vi.spyOn(Overrides, "ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.PARENTAL_BOND); vi.spyOn(Overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.SNORLAX); vi.spyOn(Overrides, "OPP_ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.INSOMNIA); @@ -57,7 +58,6 @@ describe("Abilities - Parental Bond", () => { game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); await game.phaseInterceptor.to(MoveEffectPhase, false); - vi.spyOn(game.scene, "randBattleSeedInt").mockReturnValue(15); await game.phaseInterceptor.to(DamagePhase); const firstStrikeDamage = enemyStartingHp - enemyPokemon.hp; @@ -636,7 +636,6 @@ describe("Abilities - Parental Bond", () => { game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); await game.phaseInterceptor.to(MoveEffectPhase, false); - vi.spyOn(game.scene, "randBattleSeedInt").mockReturnValue(15); await game.phaseInterceptor.to(DamagePhase); const enemyFirstHitDamage = enemyStartingHp.map((hp, i) => hp - enemyPokemon[i].hp);