This commit is contained in:
Bertie690 2025-09-21 17:23:08 -04:00
parent bf37a8ca51
commit dbaa702035
4 changed files with 12 additions and 10 deletions

View File

@ -1,4 +1,5 @@
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { BattlerIndex } from "#enums/battler-index";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
@ -24,7 +25,7 @@ describe("Abilities - Stall", () => {
game.override game.override
.battleStyle("single") .battleStyle("single")
.criticalHits(false) .criticalHits(false)
.enemySpecies(SpeciesId.REGIELEKI) .enemySpecies(SpeciesId.SHUCKLE)
.enemyAbility(AbilityId.STALL) .enemyAbility(AbilityId.STALL)
.enemyMoveset(MoveId.QUICK_ATTACK) .enemyMoveset(MoveId.QUICK_ATTACK)
.moveset([MoveId.QUICK_ATTACK, MoveId.TACKLE]); .moveset([MoveId.QUICK_ATTACK, MoveId.TACKLE]);
@ -42,7 +43,7 @@ describe("Abilities - Stall", () => {
const player = game.field.getPlayerPokemon(); const player = game.field.getPlayerPokemon();
game.move.select(MoveId.QUICK_ATTACK); game.move.select(MoveId.QUICK_ATTACK);
game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to("MoveEndPhase", false); await game.phaseInterceptor.to("MoveEndPhase", false);
// The player Pokemon (without Stall) goes first despite having lower speed than the opponent. // The player Pokemon (without Stall) goes first despite having lower speed than the opponent.
// The opponent Pokemon (with Stall) goes last despite having higher speed than the player Pokemon. // The opponent Pokemon (with Stall) goes last despite having higher speed than the player Pokemon.
@ -55,6 +56,7 @@ describe("Abilities - Stall", () => {
const player = game.field.getPlayerPokemon(); const player = game.field.getPlayerPokemon();
game.move.select(MoveId.TACKLE); game.move.select(MoveId.TACKLE);
game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to("MoveEndPhase", false); await game.phaseInterceptor.to("MoveEndPhase", false);
// The opponent Pokemon (with Stall) goes first because its move is still within a higher priority bracket than its opponent. // The opponent Pokemon (with Stall) goes first because its move is still within a higher priority bracket than its opponent.
@ -69,6 +71,7 @@ describe("Abilities - Stall", () => {
const player = game.field.getPlayerPokemon(); const player = game.field.getPlayerPokemon();
game.move.select(MoveId.TACKLE); game.move.select(MoveId.TACKLE);
game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to("MoveEndPhase", false); await game.phaseInterceptor.to("MoveEndPhase", false);

View File

@ -165,9 +165,11 @@ describe("Moves - Delayed Attacks", () => {
it("should trigger multiple pending attacks in order of creation, even if that order changes later on", async () => { it("should trigger multiple pending attacks in order of creation, even if that order changes later on", async () => {
game.override.battleStyle("double"); game.override.battleStyle("double");
await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.FEEBAS]); await game.classicMode.startBattle([SpeciesId.ALOMOMOLA, SpeciesId.BLISSEY]);
const [alomomola, blissey] = game.scene.getPlayerField(); const [alomomola, blissey, karp1, karp2] = game.scene.getField();
vi.spyOn(karp1, "getNameToRender").mockReturnValue("Karp 1");
vi.spyOn(karp2, "getNameToRender").mockReturnValue("Karp 2");
const oldOrder = game.field.getSpeedOrder(true); const oldOrder = game.field.getSpeedOrder(true);

View File

@ -52,13 +52,11 @@ import type { ModifierSelectUiHandler } from "#ui/modifier-select-ui-handler";
import type { PartyUiHandler } from "#ui/party-ui-handler"; import type { PartyUiHandler } from "#ui/party-ui-handler";
import type { StarterSelectUiHandler } from "#ui/starter-select-ui-handler"; import type { StarterSelectUiHandler } from "#ui/starter-select-ui-handler";
import type { TargetSelectUiHandler } from "#ui/target-select-ui-handler"; import type { TargetSelectUiHandler } from "#ui/target-select-ui-handler";
import { sortInSpeedOrder } from "#utils/speed-order"; import * as speedOrderUtils from "#utils/speed-order";
import fs from "node:fs"; import fs from "node:fs";
import { AES, enc } from "crypto-js"; import { AES, enc } from "crypto-js";
import { expect, vi } from "vitest"; import { expect, vi } from "vitest";
vi.mock(import("#utils/speed-order"), { spy: true });
/** /**
* Class to manage the game state and transitions between phases. * Class to manage the game state and transitions between phases.
*/ */
@ -557,8 +555,7 @@ export class GameManager {
this.scene.getField(true).map(p => p.getBattlerIndex() as Exclude<BattlerIndex, BattlerIndex.ATTACKER>), this.scene.getField(true).map(p => p.getBattlerIndex() as Exclude<BattlerIndex, BattlerIndex.ATTACKER>),
); );
expect(vi.isMockFunction(sortInSpeedOrder)).toBe(true); vi.spyOn(speedOrderUtils, "sortInSpeedOrder").mockImplementation(list => {
vi.mocked(sortInSpeedOrder).mockImplementation(list => {
list.sort((a, b) => { list.sort((a, b) => {
const aBattlerIndex = (a instanceof Pokemon ? a : a.getPokemon()).getBattlerIndex() as Exclude< const aBattlerIndex = (a instanceof Pokemon ? a : a.getPokemon()).getBattlerIndex() as Exclude<
BattlerIndex, BattlerIndex,

View File

@ -61,7 +61,7 @@ export class FieldHelper extends GameManagerHelper {
* Helper function to return all on-field {@linkcode Pokemon} in speed order (fastest first). * Helper function to return all on-field {@linkcode Pokemon} in speed order (fastest first).
* @param indices - Whether to only return {@linkcode BattlerIndex}es instead of full Pokemon objects * @param indices - Whether to only return {@linkcode BattlerIndex}es instead of full Pokemon objects
* (such as for comparison with other speed order-related mechanisms); default `false` * (such as for comparison with other speed order-related mechanisms); default `false`
* @returns An array containing the {@linkcode BattlerIndex}es of all on-field {@linkcode Pokemon} on the field in order of descending Speed. \ * @returns An array containing the {@linkcode BattlerIndex}es of all on-field `Pokemon` on the field in order of **descending** Speed. \
* Speed ties are returned in increasing order of index. * Speed ties are returned in increasing order of index.
* *
* @remarks * @remarks