Skip to content

Commit

Permalink
[Test] Update tests to enable no-crits override (#2971)
Browse files Browse the repository at this point in the history
* Update tests to enable no-crits override

* Rename variable maxHP to initialHP
  • Loading branch information
DayKev authored Jul 12, 2024
1 parent d57a7c9 commit 1965f2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
21 changes: 10 additions & 11 deletions src/test/abilities/dry_skin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
});
Expand Down
3 changes: 1 addition & 2 deletions src/test/abilities/parental_bond.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 1965f2b

Please sign in to comment.