mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-18 22:32:32 +02:00
add tests for summoning & levelup event
This commit is contained in:
parent
18a22ba860
commit
6a793641ea
@ -1,4 +1,3 @@
|
|||||||
import { beforeAll, afterEach, beforeEach, describe, vi, it, expect } from "vitest";
|
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import GameManager from "#app/test/utils/gameManager";
|
import GameManager from "#app/test/utils/gameManager";
|
||||||
import * as overrides from "#app/overrides";
|
import * as overrides from "#app/overrides";
|
||||||
@ -7,8 +6,8 @@ import { Moves } from "#enums/moves";
|
|||||||
import { Species } from "#enums/species";
|
import { Species } from "#enums/species";
|
||||||
import { Stat } from "#app/data/pokemon-stat";
|
import { Stat } from "#app/data/pokemon-stat";
|
||||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||||
|
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
|
||||||
const TIMEOUT = 20 * 1000;
|
import { TurnEndPhase } from "#app/phases";
|
||||||
|
|
||||||
describe("Moves - Power Trick", () => {
|
describe("Moves - Power Trick", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
@ -26,29 +25,15 @@ describe("Moves - Power Trick", () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
game = new GameManager(phaserGame);
|
game = new GameManager(phaserGame);
|
||||||
vi.spyOn(overrides, "STARTER_SPECIES_OVERRIDE", "get").mockReturnValue(
|
vi.spyOn(overrides, "STARTER_SPECIES_OVERRIDE", "get").mockReturnValue(Species.SHUCKLE);
|
||||||
Species.SHUCKLE
|
vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.SHUCKLE);
|
||||||
);
|
|
||||||
vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(
|
|
||||||
Species.SHUCKLE
|
|
||||||
);
|
|
||||||
vi.spyOn(overrides, "STARTING_LEVEL_OVERRIDE", "get").mockReturnValue(5);
|
vi.spyOn(overrides, "STARTING_LEVEL_OVERRIDE", "get").mockReturnValue(5);
|
||||||
vi.spyOn(overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(6);
|
vi.spyOn(overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(6);
|
||||||
vi.spyOn(overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([
|
vi.spyOn(overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.SWIFT, Moves.POWER_TRICK]);
|
||||||
Moves.POWER_TRICK,
|
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.NONE, Moves.NONE, Moves.NONE, Moves.NONE]);
|
||||||
Moves.POWER_TRICK,
|
|
||||||
Moves.POWER_TRICK,
|
|
||||||
Moves.POWER_TRICK,
|
|
||||||
]);
|
|
||||||
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([
|
|
||||||
Moves.NONE,
|
|
||||||
Moves.NONE,
|
|
||||||
Moves.NONE,
|
|
||||||
Moves.NONE,
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it(
|
test(
|
||||||
"switches raw Attack stat with its raw Defense stat",
|
"switches raw Attack stat with its raw Defense stat",
|
||||||
async () => {
|
async () => {
|
||||||
await game.startBattle([Species.SHUCKLE]);
|
await game.startBattle([Species.SHUCKLE]);
|
||||||
@ -57,16 +42,16 @@ describe("Moves - Power Trick", () => {
|
|||||||
const initialStats = [...playerPokemon.stats];
|
const initialStats = [...playerPokemon.stats];
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.POWER_TRICK));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.POWER_TRICK));
|
||||||
await game.toNextTurn();
|
await game.phaseInterceptor.to(TurnEndPhase);
|
||||||
|
|
||||||
expect(playerPokemon.getTag(BattlerTagType.POWER_TRICK)).not.toBe(undefined);
|
expect(playerPokemon.getTag(BattlerTagType.POWER_TRICK)).not.toBe(undefined);
|
||||||
expect(playerPokemon.getStat(Stat.ATK)).toBe(initialStats[Stat.DEF]);
|
expect(playerPokemon.stats[Stat.ATK]).toBe(initialStats[Stat.DEF]);
|
||||||
expect(playerPokemon.getStat(Stat.DEF)).toBe(initialStats[Stat.ATK]);
|
expect(playerPokemon.stats[Stat.DEF]).toBe(initialStats[Stat.ATK]);
|
||||||
},
|
},
|
||||||
TIMEOUT
|
20000
|
||||||
);
|
);
|
||||||
|
|
||||||
it(
|
test(
|
||||||
"using power trick again will reset stat change",
|
"using power trick again will reset stat change",
|
||||||
async () => {
|
async () => {
|
||||||
await game.startBattle([Species.SHUCKLE]);
|
await game.startBattle([Species.SHUCKLE]);
|
||||||
@ -78,12 +63,63 @@ describe("Moves - Power Trick", () => {
|
|||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.POWER_TRICK));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.POWER_TRICK));
|
||||||
await game.toNextTurn();
|
await game.phaseInterceptor.to(TurnEndPhase);
|
||||||
|
|
||||||
expect(playerPokemon.getTag(BattlerTagType.POWER_TRICK)).toBe(undefined);
|
expect(playerPokemon.getTag(BattlerTagType.POWER_TRICK)).toBe(undefined);
|
||||||
expect(playerPokemon.getStat(Stat.ATK)).toBe(initialStats[Stat.ATK]);
|
expect(playerPokemon.stats[Stat.ATK]).toBe(initialStats[Stat.ATK]);
|
||||||
expect(playerPokemon.getStat(Stat.DEF)).toBe(initialStats[Stat.DEF]);
|
expect(playerPokemon.stats[Stat.DEF]).toBe(initialStats[Stat.DEF]);
|
||||||
},
|
},
|
||||||
TIMEOUT
|
20000
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
"effect disappears with summoning event",
|
||||||
|
async () => {
|
||||||
|
await game.startBattle([Species.SHUCKLE]);
|
||||||
|
|
||||||
|
const playerPokemon = game.scene.getPlayerField()[0];
|
||||||
|
const initialStats = [...playerPokemon.stats];
|
||||||
|
|
||||||
|
game.doAttack(getMovePosition(game.scene, 0, Moves.POWER_TRICK));
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
game.doSwitchPokemon(0);
|
||||||
|
await game.phaseInterceptor.to(TurnEndPhase);
|
||||||
|
|
||||||
|
expect(playerPokemon.getTag(BattlerTagType.POWER_TRICK)).toBe(undefined);
|
||||||
|
expect(playerPokemon.stats[Stat.ATK]).toBe(initialStats[Stat.ATK]);
|
||||||
|
expect(playerPokemon.stats[Stat.DEF]).toBe(initialStats[Stat.DEF]);
|
||||||
|
},
|
||||||
|
20000
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
"effect remains after levelup event",
|
||||||
|
async () => {
|
||||||
|
await game.startBattle([Species.SHUCKLE]);
|
||||||
|
|
||||||
|
const playerPokemon = game.scene.getPlayerField()[0];
|
||||||
|
const enemyPokemon = game.scene.getEnemyField()[0];
|
||||||
|
const initialLevel = playerPokemon.level;
|
||||||
|
|
||||||
|
enemyPokemon.hp = 1;
|
||||||
|
|
||||||
|
game.doAttack(getMovePosition(game.scene, 0, Moves.POWER_TRICK));
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SWIFT));
|
||||||
|
await game.phaseInterceptor.to(TurnEndPhase);
|
||||||
|
|
||||||
|
const expectedStats = [...playerPokemon.stats];
|
||||||
|
|
||||||
|
// recalculate stats for getting base Stats to compare
|
||||||
|
playerPokemon.calculateStats();
|
||||||
|
|
||||||
|
expect(playerPokemon.level).toBeGreaterThan(initialLevel);
|
||||||
|
expect(playerPokemon.getTag(BattlerTagType.POWER_TRICK)).not.toBe(undefined);
|
||||||
|
expect(playerPokemon.stats[Stat.ATK]).toBe(expectedStats[Stat.DEF]);
|
||||||
|
expect(playerPokemon.stats[Stat.DEF]).toBe(expectedStats[Stat.ATK]);
|
||||||
|
},
|
||||||
|
20000
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user