mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-23 23:13:42 +02:00
* Add new priority queues * Add dynamic queue manager * Add timing modifier and fix post speed ordering * Make `phaseQueue` private * Fix `gameManager.setTurnOrder` * Update `findPhase` to also check dynamic queues * Modify existing phase manager methods to check dynamic queues * Fix move order persisting through tests * Fix magic coat/bounce * Use append for magic coat/bounce * Remove `getSpeedOrder` from `TurnStartPhase`, fix references to `getCommandOrder` in tests * Fix round queuing last instead of next * Add quick draw application * Add quick claw activation * Fix turn order tracking * Add move header queue to fix ordering * Fix abilities activating immediately on summon * Fix `postsummonphases` being shuffled (need to handle speed ties differently here) * Update speed order function * Add `StaticSwitchSummonPhase` * Fix magic coat/bounce error from conflict resolution * Remove conditional queue * Fix dancer and baton pass tests * Automatically queue consecutive Pokémon phases as dynamic * Move turn end phases queuing back to `TurnStartPhase` * Fix `LearnMovePhase` * Remove `PrependSplice` * Move DQM to phase manager * Fix various phases being pushed instead of unshifted * Remove `StaticSwitchSummonPhase` * Ensure the top queue is always at length - 1 * Fix encounter `PostSummonPhase`s and Revival Blessing * Fix move headers * Remove implicit ordering from DQM * Fix `PostSummonPhase`s in encounters running too early * Fix `tryRemovePhase` usages * Add `MovePhase` after `MoveEndPhase` automatically * Implement an `inSpeedOrder` function * Merge fixes * Fix encounter rewards * Defer `FaintPhase`s where splice was used previously * Separate speed order utils to avoid circular imports * Temporarily disable lunar dance test * Simplify deferral * Remove move priority modifier * Fix TS errors in code files * Fix ts errors in tests * Fix more test files * Fix postsummon + checkswitch ability activations * Fix `removeAll` * Reposition `positionalTagPhase` * Re-add `startCurrentPhase` * Avoid overwriting `currentPhase` after `turnStart` * Delete `switchSummonPhasePriorityQueue` * Update `phase-manager.ts` * Remove uses of `isNullOrUndefined` * Rename deferral methods * Update docs and use `getPlayerField(true)` in turn start phase * Use `.getEnemyField(true)` * Update docs for post summon phase priority queue (psppq) * Update speed order utils * Remove null from `nextPhase` * Update move phase timing modifier docs * Remove mention of phases from base priority queue class * Remove and replace `applyInSpeedOrder` * Don't sort weather effect phases * Order priority queues before removing - Add some `readonly` and `public` modifiers - Remove unused `queuedPhases` field from `MoveEffectPhase` * Fix linting in `phase-manager.ts` * Remove unnecessary turn order modification in Rage Fist test --------- Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
131 lines
5.7 KiB
TypeScript
131 lines
5.7 KiB
TypeScript
import { AbilityId } from "#enums/ability-id";
|
|
import { BattlerIndex } from "#enums/battler-index";
|
|
import { MoveId } from "#enums/move-id";
|
|
import { SpeciesId } from "#enums/species-id";
|
|
import type { MovePhase } from "#phases/move-phase";
|
|
import { GameManager } from "#test/test-utils/game-manager";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
describe("Battle order", () => {
|
|
let phaserGame: Phaser.Game;
|
|
let game: GameManager;
|
|
|
|
beforeAll(() => {
|
|
phaserGame = new Phaser.Game({
|
|
type: Phaser.HEADLESS,
|
|
});
|
|
});
|
|
|
|
afterEach(() => {
|
|
game.phaseInterceptor.restoreOg();
|
|
});
|
|
|
|
beforeEach(() => {
|
|
game = new GameManager(phaserGame);
|
|
game.override
|
|
.battleStyle("single")
|
|
.enemySpecies(SpeciesId.MEWTWO)
|
|
.enemyAbility(AbilityId.INSOMNIA)
|
|
.ability(AbilityId.INSOMNIA)
|
|
.moveset([MoveId.TACKLE]);
|
|
});
|
|
|
|
it("opponent faster than player 50 vs 150", async () => {
|
|
await game.classicMode.startBattle([SpeciesId.BULBASAUR]);
|
|
|
|
const playerPokemon = game.field.getPlayerPokemon();
|
|
const playerStartHp = playerPokemon.hp;
|
|
const enemyPokemon = game.field.getEnemyPokemon();
|
|
const enemyStartHp = enemyPokemon.hp;
|
|
|
|
vi.spyOn(playerPokemon, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 50]); // set playerPokemon's speed to 50
|
|
vi.spyOn(enemyPokemon, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 150]); // set enemyPokemon's speed to 150
|
|
game.move.select(MoveId.TACKLE);
|
|
|
|
await game.phaseInterceptor.to("MoveEndPhase", false);
|
|
expect(playerPokemon.hp).not.toEqual(playerStartHp);
|
|
expect(enemyPokemon.hp).toEqual(enemyStartHp);
|
|
});
|
|
|
|
it("Player faster than opponent 150 vs 50", async () => {
|
|
await game.classicMode.startBattle([SpeciesId.BULBASAUR]);
|
|
|
|
const playerPokemon = game.field.getPlayerPokemon();
|
|
const playerStartHp = playerPokemon.hp;
|
|
const enemyPokemon = game.field.getEnemyPokemon();
|
|
const enemyStartHp = enemyPokemon.hp;
|
|
vi.spyOn(playerPokemon, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 150]); // set playerPokemon's speed to 150
|
|
vi.spyOn(enemyPokemon, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 50]); // set enemyPokemon's speed to 50
|
|
|
|
game.move.select(MoveId.TACKLE);
|
|
|
|
await game.phaseInterceptor.to("MoveEndPhase", false);
|
|
expect(playerPokemon.hp).toEqual(playerStartHp);
|
|
expect(enemyPokemon.hp).not.toEqual(enemyStartHp);
|
|
});
|
|
|
|
it("double - both opponents faster than player 50/50 vs 150/150", async () => {
|
|
game.override.battleStyle("double");
|
|
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.BLASTOISE]);
|
|
|
|
const playerPokemon = game.scene.getPlayerField();
|
|
const playerHps = playerPokemon.map(p => p.hp);
|
|
const enemyPokemon = game.scene.getEnemyField();
|
|
const enemyHps = enemyPokemon.map(p => p.hp);
|
|
|
|
playerPokemon.forEach(p => vi.spyOn(p, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 50])); // set both playerPokemons' speed to 50
|
|
enemyPokemon.forEach(p => vi.spyOn(p, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 150])); // set both enemyPokemons' speed to 150
|
|
|
|
game.move.select(MoveId.TACKLE);
|
|
game.move.select(MoveId.TACKLE, 1);
|
|
await game.move.selectEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER);
|
|
await game.move.selectEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER_2);
|
|
|
|
await game.phaseInterceptor.to("MoveEndPhase", true);
|
|
await game.phaseInterceptor.to("MoveEndPhase", false);
|
|
for (let i = 0; i < 2; i++) {
|
|
expect(playerPokemon[i].hp).not.toEqual(playerHps[i]);
|
|
expect(enemyPokemon[i].hp).toEqual(enemyHps[i]);
|
|
}
|
|
});
|
|
|
|
it("double - speed tie except 1 - 100/100 vs 100/150", async () => {
|
|
game.override.battleStyle("double");
|
|
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.BLASTOISE]);
|
|
|
|
const playerPokemon = game.scene.getPlayerField();
|
|
const enemyPokemon = game.scene.getEnemyField();
|
|
playerPokemon.forEach(p => vi.spyOn(p, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 100])); //set both playerPokemons' speed to 100
|
|
vi.spyOn(enemyPokemon[0], "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 100]); // set enemyPokemon's speed to 100
|
|
vi.spyOn(enemyPokemon[1], "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 150]); // set enemyPokemon's speed to 150
|
|
|
|
game.move.select(MoveId.TACKLE);
|
|
game.move.select(MoveId.TACKLE, 1);
|
|
await game.phaseInterceptor.to("MovePhase", false);
|
|
|
|
const phase = game.scene.phaseManager.getCurrentPhase() as MovePhase;
|
|
expect(phase.pokemon).toEqual(enemyPokemon[1]);
|
|
});
|
|
|
|
it("double - speed tie 100/150 vs 100/150", async () => {
|
|
game.override.battleStyle("double");
|
|
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.BLASTOISE]);
|
|
|
|
const playerPokemon = game.scene.getPlayerField();
|
|
const enemyPokemon = game.scene.getEnemyField();
|
|
vi.spyOn(playerPokemon[0], "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 100]); // set one playerPokemon's speed to 100
|
|
vi.spyOn(playerPokemon[1], "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 150]); // set other playerPokemon's speed to 150
|
|
vi.spyOn(enemyPokemon[0], "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 100]); // set one enemyPokemon's speed to 100
|
|
vi.spyOn(enemyPokemon[1], "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 150]); // set other enemyPokemon's speed to 150
|
|
|
|
game.move.select(MoveId.TACKLE);
|
|
game.move.select(MoveId.TACKLE, 1);
|
|
|
|
await game.phaseInterceptor.to("MovePhase", false);
|
|
|
|
const phase = game.scene.phaseManager.getCurrentPhase() as MovePhase;
|
|
expect(enemyPokemon[1] === phase.pokemon || playerPokemon[1] === phase.pokemon);
|
|
});
|
|
});
|