From 1752663f807ed0dcb8ead626dc3a17b8e0bbc7d9 Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Fri, 27 Dec 2024 14:43:17 +0100 Subject: [PATCH] Changing tests for illuminate, no guard, arena trap and commander to directly check the chance of a double battle. --- src/test/abilities/arena_trap.test.ts | 23 +++++++++++---- src/test/abilities/commander.test.ts | 42 +++++++++++++++++++++++++++ src/test/abilities/illuminate.test.ts | 26 ++++++++++++----- src/test/abilities/no_guard.test.ts | 27 ++++++++++++----- 4 files changed, 98 insertions(+), 20 deletions(-) diff --git a/src/test/abilities/arena_trap.test.ts b/src/test/abilities/arena_trap.test.ts index 12b9673080d..745576fc274 100644 --- a/src/test/abilities/arena_trap.test.ts +++ b/src/test/abilities/arena_trap.test.ts @@ -45,16 +45,27 @@ describe("Abilities - Arena Trap", () => { expect(enemy).toBe(game.scene.getEnemyPokemon()); }); - it("should guarantee double battle with any one LURE", async () => { + it("should increase the chance of double battles", async () => { game.override - .startingModifier([ - { name: "LURE" }, - ]) - .startingWave(2); + .moveset(Moves.SPLASH) + .ability(Abilities.ARENA_TRAP) + .enemySpecies(Species.SUNKERN) + .enemyAbility(Abilities.BALL_FETCH) + .enemyMoveset(Moves.SPLASH) + .startingWave(9); + vi.spyOn(game.scene, "getDoubleBattleChance"); await game.classicMode.startBattle(); - expect(game.scene.getEnemyField().length).toBe(2); + game.move.select(Moves.SPLASH); + await game.doKillOpponents(); + await game.toNextWave(); + expect(game.scene.getDoubleBattleChance).toHaveLastReturnedWith(8); + + game.move.select(Moves.SPLASH); + await game.doKillOpponents(); + await game.toNextWave(); + expect(game.scene.getDoubleBattleChance).toHaveLastReturnedWith(2); }); /** diff --git a/src/test/abilities/commander.test.ts b/src/test/abilities/commander.test.ts index 99b3d50797c..fcd7fc32196 100644 --- a/src/test/abilities/commander.test.ts +++ b/src/test/abilities/commander.test.ts @@ -222,3 +222,45 @@ describe("Abilities - Commander", () => { expect(enemy.isFullHp()).toBeTruthy(); }); }); + +describe("Abilities - Commander", () => { + let phaserGame: Phaser.Game; + let game: GameManager; + + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, + }); + }); + + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + }); + + it("should increase the chance of double battles", async () => { + game.override + .moveset(Moves.SPLASH) + .ability(Abilities.COMMANDER) + .enemySpecies(Species.SUNKERN) + .enemyAbility(Abilities.BALL_FETCH) + .enemyMoveset(Moves.SPLASH) + .startingWave(9); + + vi.spyOn(game.scene, "getDoubleBattleChance"); + await game.classicMode.startBattle(); + + game.move.select(Moves.SPLASH); + await game.doKillOpponents(); + await game.toNextWave(); + expect(game.scene.getDoubleBattleChance).toHaveLastReturnedWith(8); + + game.move.select(Moves.SPLASH); + await game.doKillOpponents(); + await game.toNextWave(); + expect(game.scene.getDoubleBattleChance).toHaveLastReturnedWith(2); + }); +}); diff --git a/src/test/abilities/illuminate.test.ts b/src/test/abilities/illuminate.test.ts index 4f7d3d83b51..cd55d7ee945 100644 --- a/src/test/abilities/illuminate.test.ts +++ b/src/test/abilities/illuminate.test.ts @@ -1,9 +1,10 @@ import { Stat } from "#app/enums/stat"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; -import { afterEach, beforeAll, beforeEach, describe, it, expect } from "vitest"; +import { afterEach, beforeAll, beforeEach, describe, it, expect, vi } from "vitest"; describe("Abilities - Illuminate", () => { let phaserGame: Phaser.Game; @@ -44,15 +45,26 @@ describe("Abilities - Illuminate", () => { expect(player.getStatStage(Stat.ACC)).toBe(0); }); - it("should guarantee double battle with any one LURE", async () => { + it("should increase the chance of double battles", async () => { game.override - .startingModifier([ - { name: "LURE" }, - ]) - .startingWave(2); + .moveset(Moves.SPLASH) + .ability(Abilities.ILLUMINATE) + .enemySpecies(Species.SUNKERN) + .enemyAbility(Abilities.BALL_FETCH) + .enemyMoveset(Moves.SPLASH) + .startingWave(9); + vi.spyOn(game.scene, "getDoubleBattleChance"); await game.classicMode.startBattle(); - expect(game.scene.getEnemyField().length).toBe(2); + game.move.select(Moves.SPLASH); + await game.doKillOpponents(); + await game.toNextWave(); + expect(game.scene.getDoubleBattleChance).toHaveLastReturnedWith(8); + + game.move.select(Moves.SPLASH); + await game.doKillOpponents(); + await game.toNextWave(); + expect(game.scene.getDoubleBattleChance).toHaveLastReturnedWith(2); }); }); diff --git a/src/test/abilities/no_guard.test.ts b/src/test/abilities/no_guard.test.ts index b0b454dd560..1afcba86276 100644 --- a/src/test/abilities/no_guard.test.ts +++ b/src/test/abilities/no_guard.test.ts @@ -53,15 +53,28 @@ describe("Abilities - No Guard", () => { expect(moveEffectPhase.hitCheck).toHaveReturnedWith(true); }); - it("should guarantee double battle with any one LURE", async () => { - game.override - .startingModifier([ - { name: "LURE" }, - ]) - .startingWave(2); + it("should increase the chance of double battles", async () => { + game.override + .moveset(Moves.SPLASH) + .ability(Abilities.NO_GUARD) + .enemySpecies(Species.SUNKERN) + .enemyAbility(Abilities.BALL_FETCH) + .enemyMoveset(Moves.SPLASH) + .startingWave(9); + + vi.spyOn(game.scene, "getDoubleBattleChance"); await game.classicMode.startBattle(); - expect(game.scene.getEnemyField().length).toBe(2); + game.move.select(Moves.SPLASH); + await game.doKillOpponents(); + await game.toNextWave(); + expect(game.scene.getDoubleBattleChance).toHaveLastReturnedWith(8); + + game.move.select(Moves.SPLASH); + await game.doKillOpponents(); + await game.toNextWave(); + expect(game.scene.getDoubleBattleChance).toHaveLastReturnedWith(2); }); + });