Changing tests for illuminate, no guard, arena trap and commander to directly check the chance of a double battle.

This commit is contained in:
Wlowscha 2024-12-27 14:43:17 +01:00
parent 851bb7e544
commit 1752663f80
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
4 changed files with 98 additions and 20 deletions

View File

@ -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);
});
/**

View File

@ -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);
});
});

View File

@ -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);
});
});

View File

@ -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);
});
});