mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-24 07:23:24 +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>
145 lines
6.5 KiB
TypeScript
145 lines
6.5 KiB
TypeScript
import { AbilityId } from "#enums/ability-id";
|
|
import { BattlerIndex } from "#enums/battler-index";
|
|
import { MoveId } from "#enums/move-id";
|
|
import { MoveResult } from "#enums/move-result";
|
|
import { SpeciesId } from "#enums/species-id";
|
|
import { Stat } from "#enums/stat";
|
|
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 } from "vitest";
|
|
|
|
describe("Abilities - Dancer", () => {
|
|
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("double").enemyAbility(AbilityId.BALL_FETCH);
|
|
});
|
|
|
|
// Reference Link: https://bulbapedia.bulbagarden.net/wiki/Dancer_(Ability)
|
|
|
|
it("triggers when dance moves are used, doesn't consume extra PP", async () => {
|
|
game.override.enemyAbility(AbilityId.DANCER).enemySpecies(SpeciesId.MAGIKARP).enemyMoveset(MoveId.VICTORY_DANCE);
|
|
await game.classicMode.startBattle([SpeciesId.ORICORIO, SpeciesId.FEEBAS]);
|
|
|
|
const [oricorio, feebas, magikarp1] = game.scene.getField();
|
|
game.move.changeMoveset(oricorio, [MoveId.SWORDS_DANCE, MoveId.VICTORY_DANCE, MoveId.SPLASH]);
|
|
game.move.changeMoveset(feebas, [MoveId.SWORDS_DANCE, MoveId.SPLASH]);
|
|
|
|
game.move.select(MoveId.SPLASH);
|
|
game.move.select(MoveId.SWORDS_DANCE, 1);
|
|
await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2]);
|
|
await game.phaseInterceptor.to("MovePhase"); // feebas uses swords dance
|
|
await game.phaseInterceptor.to("MovePhase", false); // oricorio copies swords dance
|
|
|
|
// Dancer order will be Magikarp, Oricorio, Magikarp based on set turn order
|
|
let currentPhase = game.scene.phaseManager.getCurrentPhase() as MovePhase;
|
|
expect(currentPhase.pokemon).toBe(magikarp1);
|
|
expect(currentPhase.move.moveId).toBe(MoveId.SWORDS_DANCE);
|
|
|
|
await game.phaseInterceptor.to("MoveEndPhase"); // end oricorio's move
|
|
await game.phaseInterceptor.to("MovePhase"); // magikarp 1 copies swords dance
|
|
await game.phaseInterceptor.to("MovePhase"); // magikarp 2 copies swords dance
|
|
await game.phaseInterceptor.to("MovePhase"); // magikarp (left) uses victory dance
|
|
await game.phaseInterceptor.to("MovePhase", false); // oricorio copies magikarp's victory dance
|
|
|
|
currentPhase = game.scene.phaseManager.getCurrentPhase() as MovePhase;
|
|
expect(currentPhase.pokemon).toBe(oricorio);
|
|
expect(currentPhase.move.moveId).toBe(MoveId.VICTORY_DANCE);
|
|
|
|
await game.phaseInterceptor.to("BerryPhase"); // finish the turn
|
|
|
|
// doesn't use PP if copied move is also in moveset
|
|
expect(oricorio.moveset[0]?.ppUsed).toBe(0);
|
|
expect(oricorio.moveset[1]?.ppUsed).toBe(0);
|
|
});
|
|
|
|
// TODO: Enable after Dancer rework to not push to move history
|
|
it.todo("should not count as the last move used for mirror move/instruct", async () => {
|
|
game.override
|
|
.moveset([MoveId.FIERY_DANCE, MoveId.REVELATION_DANCE])
|
|
.enemyMoveset([MoveId.INSTRUCT, MoveId.MIRROR_MOVE, MoveId.SPLASH])
|
|
.enemySpecies(SpeciesId.SHUCKLE)
|
|
.enemyLevel(10);
|
|
await game.classicMode.startBattle([SpeciesId.ORICORIO, SpeciesId.FEEBAS]);
|
|
|
|
const oricorio = game.field.getPlayerPokemon();
|
|
const shuckle2 = game.scene.getEnemyField()[1];
|
|
|
|
game.move.select(MoveId.REVELATION_DANCE, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2);
|
|
game.move.select(MoveId.FIERY_DANCE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2);
|
|
await game.move.selectEnemyMove(MoveId.INSTRUCT, BattlerIndex.PLAYER);
|
|
await game.move.selectEnemyMove(MoveId.MIRROR_MOVE, BattlerIndex.PLAYER);
|
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2, BattlerIndex.ENEMY]);
|
|
await game.phaseInterceptor.to("MovePhase"); // Oricorio rev dance
|
|
await game.phaseInterceptor.to("MovePhase"); // Feebas fiery dance
|
|
await game.phaseInterceptor.to("MovePhase"); // Oricorio fiery dance (from dancer)
|
|
await game.phaseInterceptor.to("MoveEndPhase", false);
|
|
// dancer copied move doesn't appear in move history
|
|
expect(oricorio.getLastXMoves(-1)[0].move).toBe(MoveId.REVELATION_DANCE);
|
|
|
|
await game.phaseInterceptor.to("MovePhase"); // shuckle 2 mirror moves oricorio
|
|
await game.phaseInterceptor.to("MovePhase"); // calls instructed rev dance
|
|
let currentPhase = game.scene.phaseManager.getCurrentPhase() as MovePhase;
|
|
expect(currentPhase.pokemon).toBe(shuckle2);
|
|
expect(currentPhase.move.moveId).toBe(MoveId.REVELATION_DANCE);
|
|
|
|
await game.phaseInterceptor.to("MovePhase"); // shuckle 1 instructs oricorio
|
|
await game.phaseInterceptor.to("MovePhase");
|
|
currentPhase = game.scene.phaseManager.getCurrentPhase() as MovePhase;
|
|
expect(currentPhase.pokemon).toBe(oricorio);
|
|
expect(currentPhase.move.moveId).toBe(MoveId.REVELATION_DANCE);
|
|
});
|
|
|
|
it("should not break subsequent last hit only moves", async () => {
|
|
game.override.battleStyle("single");
|
|
await game.classicMode.startBattle([SpeciesId.ORICORIO, SpeciesId.FEEBAS]);
|
|
|
|
const [oricorio, feebas] = game.scene.getPlayerParty();
|
|
|
|
game.move.use(MoveId.BATON_PASS);
|
|
game.doSelectPartyPokemon(1);
|
|
await game.move.forceEnemyMove(MoveId.SWORDS_DANCE);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
|
expect(game.field.getPlayerPokemon()).toBe(feebas);
|
|
expect(feebas.getStatStage(Stat.ATK)).toBe(2);
|
|
expect(oricorio.isOnField()).toBe(false);
|
|
expect(oricorio.visible).toBe(false);
|
|
});
|
|
|
|
it("should not trigger while flinched", async () => {
|
|
game.override.battleStyle("double").moveset(MoveId.SPLASH).enemyMoveset([MoveId.SWORDS_DANCE, MoveId.FAKE_OUT]);
|
|
await game.classicMode.startBattle([SpeciesId.ORICORIO]);
|
|
|
|
const oricorio = game.field.getPlayerPokemon();
|
|
expect(oricorio).toBeDefined();
|
|
|
|
// get faked out and copy swords dance
|
|
game.move.select(MoveId.SPLASH);
|
|
await game.move.forceEnemyMove(MoveId.SWORDS_DANCE);
|
|
await game.move.forceEnemyMove(MoveId.FAKE_OUT, BattlerIndex.PLAYER);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
expect(oricorio.getLastXMoves(-1)[0]).toMatchObject({
|
|
move: MoveId.NONE,
|
|
result: MoveResult.FAIL,
|
|
});
|
|
expect(oricorio.getStatStage(Stat.ATK)).toBe(0);
|
|
});
|
|
});
|