[Dev] Update changeTurnOrder name to mockTurnOrder (naming convention) (#3422)
* change changeTurnOrder to mockTurnOrder * update docs
This commit is contained in:
parent
0bd32b7a76
commit
9ff8685752
|
@ -11,7 +11,7 @@ import { Moves } from "#enums/moves";
|
|||
import { Species } from "#enums/species";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
import { changeTurnOrder } from "../utils/testUtils";
|
||||
import { mockTurnOrder } from "../utils/testUtils";
|
||||
import { BattlerIndex } from "#app/battle.js";
|
||||
|
||||
|
||||
|
@ -57,7 +57,7 @@ describe("Abilities - Serene Grace", () => {
|
|||
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
|
||||
});
|
||||
|
||||
await changeTurnOrder(game, [BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await mockTurnOrder(game, [BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
||||
|
||||
// Check chance of Air Slash without Serene Grace
|
||||
|
@ -90,7 +90,7 @@ describe("Abilities - Serene Grace", () => {
|
|||
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
|
||||
});
|
||||
|
||||
await changeTurnOrder(game, [BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await mockTurnOrder(game, [BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
||||
|
||||
// Check chance of Air Slash with Serene Grace
|
||||
|
|
|
@ -11,7 +11,7 @@ import { Moves } from "#enums/moves";
|
|||
import { Species } from "#enums/species";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
import { changeTurnOrder } from "../utils/testUtils";
|
||||
import { mockTurnOrder } from "../utils/testUtils";
|
||||
import { BattlerIndex } from "#app/battle.js";
|
||||
|
||||
|
||||
|
@ -58,7 +58,7 @@ describe("Abilities - Sheer Force", () => {
|
|||
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
|
||||
});
|
||||
|
||||
await changeTurnOrder(game, [BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await mockTurnOrder(game, [BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
||||
|
||||
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
|
||||
|
@ -97,7 +97,7 @@ describe("Abilities - Sheer Force", () => {
|
|||
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
|
||||
});
|
||||
|
||||
await changeTurnOrder(game, [BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await mockTurnOrder(game, [BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
||||
|
||||
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
|
||||
|
@ -136,7 +136,7 @@ describe("Abilities - Sheer Force", () => {
|
|||
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
|
||||
});
|
||||
|
||||
await changeTurnOrder(game, [BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await mockTurnOrder(game, [BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
||||
|
||||
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
|
||||
|
@ -177,7 +177,7 @@ describe("Abilities - Sheer Force", () => {
|
|||
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
|
||||
});
|
||||
|
||||
await changeTurnOrder(game, [BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await mockTurnOrder(game, [BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
||||
|
||||
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
|
||||
|
|
|
@ -12,7 +12,7 @@ import { Species } from "#enums/species";
|
|||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
import { BattlerIndex } from "#app/battle.js";
|
||||
import { changeTurnOrder } from "../utils/testUtils";
|
||||
import { mockTurnOrder } from "../utils/testUtils";
|
||||
|
||||
|
||||
describe("Abilities - Shield Dust", () => {
|
||||
|
@ -58,7 +58,7 @@ describe("Abilities - Shield Dust", () => {
|
|||
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
|
||||
});
|
||||
|
||||
await changeTurnOrder(game, [BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await mockTurnOrder(game, [BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
||||
|
||||
// Shield Dust negates secondary effect
|
||||
|
|
|
@ -12,7 +12,7 @@ import { Species } from "#enums/species";
|
|||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
|
||||
import { BattlerIndex } from "#app/battle.js";
|
||||
import { changeTurnOrder } from "../utils/testUtils";
|
||||
import { mockTurnOrder } from "../utils/testUtils";
|
||||
|
||||
const TIMEOUT = 20 * 1000;
|
||||
|
||||
|
@ -58,7 +58,7 @@ describe("Abilities - ZEN MODE", () => {
|
|||
const movePosition = getMovePosition(game.scene, 0, moveToUse);
|
||||
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
|
||||
});
|
||||
await changeTurnOrder(game, [BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
||||
await mockTurnOrder(game, [BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
||||
await game.phaseInterceptor.to(DamagePhase, false);
|
||||
// await game.phaseInterceptor.runFrom(DamagePhase).to(DamagePhase, false);
|
||||
const damagePhase = game.scene.getCurrentPhase() as DamagePhase;
|
||||
|
@ -86,7 +86,7 @@ describe("Abilities - ZEN MODE", () => {
|
|||
const movePosition = getMovePosition(game.scene, 0, moveToUse);
|
||||
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
|
||||
});
|
||||
await changeTurnOrder(game, [BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
||||
await mockTurnOrder(game, [BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
||||
await game.phaseInterceptor.to(QuietFormChangePhase);
|
||||
await game.phaseInterceptor.to(TurnInitPhase, false);
|
||||
expect(game.scene.getParty()[0].hp).not.toBe(100);
|
||||
|
@ -111,7 +111,7 @@ describe("Abilities - ZEN MODE", () => {
|
|||
const movePosition = getMovePosition(game.scene, 0, moveToUse);
|
||||
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
|
||||
});
|
||||
await changeTurnOrder(game, [BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
||||
await mockTurnOrder(game, [BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
||||
await game.phaseInterceptor.to(DamagePhase, false);
|
||||
// await game.phaseInterceptor.runFrom(DamagePhase).to(DamagePhase, false);
|
||||
const damagePhase = game.scene.getCurrentPhase() as DamagePhase;
|
||||
|
|
|
@ -8,7 +8,7 @@ import { Moves } from "#enums/moves";
|
|||
import { Species } from "#enums/species";
|
||||
import Phase from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { changeTurnOrder } from "#test/utils/testUtils";
|
||||
import { mockTurnOrder } from "#test/utils/testUtils";
|
||||
|
||||
describe("Items - Leek", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
|
@ -44,7 +44,7 @@ describe("Items - Leek", () => {
|
|||
|
||||
game.doAttack(0);
|
||||
|
||||
await changeTurnOrder(game, [BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await mockTurnOrder(game, [BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
|
||||
await game.phaseInterceptor.to(MoveEffectPhase);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import { Moves } from "#enums/moves";
|
|||
import { Species } from "#enums/species";
|
||||
import Phase from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { changeTurnOrder } from "#test/utils/testUtils";
|
||||
import { mockTurnOrder } from "#test/utils/testUtils";
|
||||
|
||||
describe("Items - Scope Lens", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
|
@ -43,7 +43,7 @@ describe("Items - Scope Lens", () => {
|
|||
]);
|
||||
|
||||
game.doAttack(0);
|
||||
await changeTurnOrder(game, [ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
||||
await mockTurnOrder(game, [ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
||||
|
||||
await game.phaseInterceptor.to(MoveEffectPhase);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import { allMoves } from "#app/data/move";
|
|||
import { BattlerIndex } from "#app/battle";
|
||||
import { Species } from "#enums/species";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { changeTurnOrder } from "#test/utils/testUtils";
|
||||
import { mockTurnOrder } from "#test/utils/testUtils";
|
||||
|
||||
describe("Moves - Fusion Flare and Fusion Bolt", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
|
@ -56,7 +56,7 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
|
|||
game.doSelectTarget(BattlerIndex.ENEMY);
|
||||
|
||||
// Force user party to act before enemy party
|
||||
await changeTurnOrder(game, [ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
|
||||
await mockTurnOrder(game, [ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
|
||||
|
||||
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
||||
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id);
|
||||
|
@ -82,7 +82,7 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
|
|||
game.doSelectTarget(BattlerIndex.ENEMY);
|
||||
|
||||
// Force user party to act before enemy party
|
||||
await changeTurnOrder(game, [ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
|
||||
await mockTurnOrder(game, [ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
|
||||
|
||||
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
||||
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id);
|
||||
|
@ -108,7 +108,7 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
|
|||
game.doSelectTarget(0);
|
||||
|
||||
// Force first enemy to act (and fail) in between party
|
||||
await changeTurnOrder(game, [ BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]);
|
||||
await mockTurnOrder(game, [ BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]);
|
||||
|
||||
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
||||
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id);
|
||||
|
@ -140,7 +140,7 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
|
|||
game.doSelectTarget(BattlerIndex.ENEMY);
|
||||
|
||||
// Force first enemy to act in between party
|
||||
await changeTurnOrder(game, [ BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]);
|
||||
await mockTurnOrder(game, [ BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]);
|
||||
|
||||
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
||||
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id);
|
||||
|
@ -170,7 +170,7 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
|
|||
game.doSelectTarget(BattlerIndex.PLAYER);
|
||||
|
||||
// Force user party to act before enemy party
|
||||
await changeTurnOrder(game, [ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
|
||||
await mockTurnOrder(game, [ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
|
||||
|
||||
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
||||
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id);
|
||||
|
@ -222,7 +222,7 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
|
|||
game.doSelectTarget(BattlerIndex.ENEMY);
|
||||
|
||||
// Force first enemy to act in between party
|
||||
await changeTurnOrder(game, [ BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]);
|
||||
await mockTurnOrder(game, [ BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]);
|
||||
|
||||
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
||||
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id);
|
||||
|
@ -284,7 +284,7 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
|
|||
game.doSelectTarget(BattlerIndex.PLAYER);
|
||||
|
||||
// Force first enemy to act in between party
|
||||
await changeTurnOrder(game, [ BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]);
|
||||
await mockTurnOrder(game, [ BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]);
|
||||
|
||||
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
||||
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id);
|
||||
|
|
|
@ -6,7 +6,7 @@ import { MoveResult } from "#app/field/pokemon.js";
|
|||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import { getMovePosition } from "#test/utils/gameManagerUtils";
|
||||
import { changeTurnOrder, SPLASH_ONLY } from "#test/utils/testUtils";
|
||||
import { mockTurnOrder, SPLASH_ONLY } from "#test/utils/testUtils";
|
||||
|
||||
const TIMEOUT = 20 * 1000;
|
||||
|
||||
|
@ -75,7 +75,7 @@ describe("Moves - Gastro Acid", () => {
|
|||
|
||||
game.doAttack(getMovePosition(game.scene, 0, Moves.CORE_ENFORCER));
|
||||
// Force player to be slower to enable Core Enforcer to proc its suppression effect
|
||||
await changeTurnOrder(game, [BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
||||
await mockTurnOrder(game, [BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
||||
|
||||
await game.phaseInterceptor.to("TurnInitPhase");
|
||||
|
||||
|
|
|
@ -40,15 +40,16 @@ export function removeEnemyHeldItems(game: GameManager): void {
|
|||
}
|
||||
|
||||
/**
|
||||
* Used to modify the turn order. Will advance the turn to {@link TurnStartPhase}
|
||||
* @param game The {@link GameManager} instance
|
||||
* @param order The turn order to set
|
||||
* Intercepts `TurnStartPhase` and mocks the getOrder's return value {@linkcode TurnStartPhase.getOrder}
|
||||
* Used to modify the turn order.
|
||||
* @param {GameManager} game The GameManager instance
|
||||
* @param {BattlerIndex[]} order The turn order to set
|
||||
* @example
|
||||
* ```ts
|
||||
* await changeTurnOrder(game, [BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2]);
|
||||
* await mockTurnOrder(game, [BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2]);
|
||||
* ```
|
||||
*/
|
||||
export async function changeTurnOrder(game: GameManager, order: BattlerIndex[]): Promise<void> {
|
||||
export async function mockTurnOrder(game: GameManager, order: BattlerIndex[]): Promise<void> {
|
||||
await game.phaseInterceptor.to(TurnStartPhase, false);
|
||||
|
||||
vi.spyOn(game.scene.getCurrentPhase() as TurnStartPhase, "getOrder").mockReturnValue(order);
|
||||
|
|
Loading…
Reference in New Issue