pokerogue/src/test/moves/dynamax_cannon.test.ts
2024-07-29 07:37:35 -07:00

176 lines
7.1 KiB
TypeScript

import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import Phaser from "phaser";
import GameManager from "#app/test/utils/gameManager";
import Overrides from "#app/overrides";
import { MoveEffectPhase, DamagePhase, TurnStartPhase } from "#app/phases";
import { getMovePosition } from "#app/test/utils/gameManagerUtils";
import { allMoves } from "#app/data/move";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { BattlerIndex } from "#app/battle";
describe("Moves - Dynamax Cannon", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
const dynamaxCannon = allMoves[Moves.DYNAMAX_CANNON];
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
vi.spyOn(Overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([ dynamaxCannon.id ]);
vi.spyOn(Overrides, "STARTING_LEVEL_OVERRIDE", "get").mockReturnValue(200);
// Note that, for Waves 1-10, the level cap is 10
game.override.startingWave(1);
vi.spyOn(Overrides, "BATTLE_TYPE_OVERRIDE", "get").mockReturnValue("single");
vi.spyOn(Overrides, "NEVER_CRIT_OVERRIDE", "get").mockReturnValue(true);
vi.spyOn(Overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.MAGIKARP);
vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([ Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH ]);
vi.spyOn(dynamaxCannon, "calculateBattlePower");
});
it("should return 100 power against an enemy below level cap", async() => {
vi.spyOn(Overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(1);
await game.startBattle([
Species.ETERNATUS,
]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id));
await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id);
await game.phaseInterceptor.to(DamagePhase, false);
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(100);
}, 20000);
it("should return 100 power against an enemy at level cap", async() => {
vi.spyOn(Overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(10);
await game.startBattle([
Species.ETERNATUS,
]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id));
await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id);
await game.phaseInterceptor.to(DamagePhase, false);
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(100);
}, 20000);
it("should return 120 power against an enemy 1% above level cap", async() => {
vi.spyOn(Overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(101);
await game.startBattle([
Species.ETERNATUS,
]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id));
await game.phaseInterceptor.to(MoveEffectPhase, false);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
expect(phase.move.moveId).toBe(dynamaxCannon.id);
// Force level cap to be 100
vi.spyOn(phase.getTarget().scene, "getMaxExpLevel").mockReturnValue(100);
await game.phaseInterceptor.to(DamagePhase, false);
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(120);
}, 20000);
it("should return 140 power against an enemy 2% above level capp", async() => {
vi.spyOn(Overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(102);
await game.startBattle([
Species.ETERNATUS,
]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id));
await game.phaseInterceptor.to(MoveEffectPhase, false);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
expect(phase.move.moveId).toBe(dynamaxCannon.id);
// Force level cap to be 100
vi.spyOn(phase.getTarget().scene, "getMaxExpLevel").mockReturnValue(100);
await game.phaseInterceptor.to(DamagePhase, false);
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(140);
}, 20000);
it("should return 160 power against an enemy 3% above level cap", async() => {
vi.spyOn(Overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(103);
await game.startBattle([
Species.ETERNATUS,
]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id));
await game.phaseInterceptor.to(MoveEffectPhase, false);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
expect(phase.move.moveId).toBe(dynamaxCannon.id);
// Force level cap to be 100
vi.spyOn(phase.getTarget().scene, "getMaxExpLevel").mockReturnValue(100);
await game.phaseInterceptor.to(DamagePhase, false);
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(160);
}, 20000);
it("should return 180 power against an enemy 4% above level cap", async() => {
vi.spyOn(Overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(104);
await game.startBattle([
Species.ETERNATUS,
]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id));
await game.phaseInterceptor.to(MoveEffectPhase, false);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
expect(phase.move.moveId).toBe(dynamaxCannon.id);
// Force level cap to be 100
vi.spyOn(phase.getTarget().scene, "getMaxExpLevel").mockReturnValue(100);
await game.phaseInterceptor.to(DamagePhase, false);
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(180);
}, 20000);
it("should return 200 power against an enemy 5% above level cap", async() => {
vi.spyOn(Overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(105);
await game.startBattle([
Species.ETERNATUS,
]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id));
await game.phaseInterceptor.to(MoveEffectPhase, false);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
expect(phase.move.moveId).toBe(dynamaxCannon.id);
// Force level cap to be 100
vi.spyOn(phase.getTarget().scene, "getMaxExpLevel").mockReturnValue(100);
await game.phaseInterceptor.to(DamagePhase, false);
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(200);
}, 20000);
it("should return 200 power against an enemy way above level cap", async() => {
vi.spyOn(Overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(999);
await game.startBattle([
Species.ETERNATUS,
]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id));
await game.phaseInterceptor.to(TurnStartPhase, false);
// Force user to act before enemy
vi.spyOn((game.scene.getCurrentPhase() as TurnStartPhase), "getOrder").mockReturnValue([ BattlerIndex.PLAYER, BattlerIndex. ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id);
await game.phaseInterceptor.to(DamagePhase, false);
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(200);
}, 20000);
});