mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-03 23:12:20 +02:00
Fix gameManager.setTurnOrder
This commit is contained in:
parent
08090a8c14
commit
46c709ffad
@ -228,7 +228,7 @@ export class PhaseManager {
|
|||||||
private phaseQueuePrependSpliceIndex = -1;
|
private phaseQueuePrependSpliceIndex = -1;
|
||||||
private nextCommandPhaseQueue: Phase[] = [];
|
private nextCommandPhaseQueue: Phase[] = [];
|
||||||
|
|
||||||
private dynamicQueueManager = new DynamicQueueManager();
|
public dynamicQueueManager = new DynamicQueueManager();
|
||||||
|
|
||||||
private currentPhase: Phase | null = null;
|
private currentPhase: Phase | null = null;
|
||||||
private standbyPhase: Phase | null = null;
|
private standbyPhase: Phase | null = null;
|
||||||
|
@ -6,6 +6,7 @@ import { MovePhasePriorityQueue } from "#app/queues/move-phase-priority-queue";
|
|||||||
import type { PhasePriorityQueue } from "#app/queues/phase-priority-queue";
|
import type { PhasePriorityQueue } from "#app/queues/phase-priority-queue";
|
||||||
import { PokemonPhasePriorityQueue } from "#app/queues/pokemon-phase-priority-queue";
|
import { PokemonPhasePriorityQueue } from "#app/queues/pokemon-phase-priority-queue";
|
||||||
import { PostSummonPhasePriorityQueue } from "#app/queues/post-summon-phase-priority-queue";
|
import { PostSummonPhasePriorityQueue } from "#app/queues/post-summon-phase-priority-queue";
|
||||||
|
import type { BattlerIndex } from "#enums/battler-index";
|
||||||
import type { MovePhaseTimingModifier } from "#enums/move-phase-timing-modifier";
|
import type { MovePhaseTimingModifier } from "#enums/move-phase-timing-modifier";
|
||||||
export class DynamicQueueManager {
|
export class DynamicQueueManager {
|
||||||
private dynamicPhaseMap: Map<PhaseString, PhasePriorityQueue<Phase>>;
|
private dynamicPhaseMap: Map<PhaseString, PhasePriorityQueue<Phase>>;
|
||||||
@ -43,4 +44,8 @@ export class DynamicQueueManager {
|
|||||||
const movePhaseQueue: MovePhasePriorityQueue = this.dynamicPhaseMap.get("MovePhase") as MovePhasePriorityQueue;
|
const movePhaseQueue: MovePhasePriorityQueue = this.dynamicPhaseMap.get("MovePhase") as MovePhasePriorityQueue;
|
||||||
movePhaseQueue.setTimingModifier(condition, modifier);
|
movePhaseQueue.setTimingModifier(condition, modifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setMoveOrder(order: BattlerIndex[]) {
|
||||||
|
(this.dynamicPhaseMap.get("MovePhase") as MovePhasePriorityQueue).setMoveOrder(order);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import type { PhaseConditionFunc } from "#app/@types/phase-condition";
|
|||||||
import type { MovePhase } from "#app/phases/move-phase";
|
import type { MovePhase } from "#app/phases/move-phase";
|
||||||
import { PokemonPhasePriorityQueue } from "#app/queues/pokemon-phase-priority-queue";
|
import { PokemonPhasePriorityQueue } from "#app/queues/pokemon-phase-priority-queue";
|
||||||
import { isNullOrUndefined } from "#app/utils/common";
|
import { isNullOrUndefined } from "#app/utils/common";
|
||||||
|
import type { BattlerIndex } from "#enums/battler-index";
|
||||||
import type { MovePhaseTimingModifier } from "#enums/move-phase-timing-modifier";
|
import type { MovePhaseTimingModifier } from "#enums/move-phase-timing-modifier";
|
||||||
|
|
||||||
export class MovePhasePriorityQueue extends PokemonPhasePriorityQueue<MovePhase> {
|
export class MovePhasePriorityQueue extends PokemonPhasePriorityQueue<MovePhase> {
|
||||||
@ -17,6 +18,10 @@ export class MovePhasePriorityQueue extends PokemonPhasePriorityQueue<MovePhase>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setMoveOrder(order: BattlerIndex[]) {
|
||||||
|
this.setOrder = order;
|
||||||
|
}
|
||||||
|
|
||||||
private sortPostSpeed(): void {
|
private sortPostSpeed(): void {
|
||||||
this.queue.sort((a: MovePhase, b: MovePhase) => {
|
this.queue.sort((a: MovePhase, b: MovePhase) => {
|
||||||
const priority = [a, b].map(movePhase => {
|
const priority = [a, b].map(movePhase => {
|
||||||
|
@ -2,9 +2,19 @@ import type { PartyMemberPokemonPhase } from "#app/phases/party-member-pokemon-p
|
|||||||
import type { PokemonPhase } from "#app/phases/pokemon-phase";
|
import type { PokemonPhase } from "#app/phases/pokemon-phase";
|
||||||
import { PhasePriorityQueue } from "#app/queues/phase-priority-queue";
|
import { PhasePriorityQueue } from "#app/queues/phase-priority-queue";
|
||||||
import { sortInSpeedOrder } from "#app/utils/speed-order";
|
import { sortInSpeedOrder } from "#app/utils/speed-order";
|
||||||
|
import type { BattlerIndex } from "#enums/battler-index";
|
||||||
|
|
||||||
export class PokemonPhasePriorityQueue<T extends PokemonPhase | PartyMemberPokemonPhase> extends PhasePriorityQueue<T> {
|
export class PokemonPhasePriorityQueue<T extends PokemonPhase | PartyMemberPokemonPhase> extends PhasePriorityQueue<T> {
|
||||||
|
protected setOrder: BattlerIndex[] | undefined;
|
||||||
public override reorder(): void {
|
public override reorder(): void {
|
||||||
this.queue = sortInSpeedOrder(this.queue);
|
if (this.setOrder) {
|
||||||
|
this.queue.sort(
|
||||||
|
(a, b) =>
|
||||||
|
this.setOrder!.indexOf(a.getPokemon().getBattlerIndex()) -
|
||||||
|
this.setOrder!.indexOf(b.getPokemon().getBattlerIndex()),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
this.queue = sortInSpeedOrder(this.queue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -531,7 +531,7 @@ export default class GameManager {
|
|||||||
async setTurnOrder(order: BattlerIndex[]): Promise<void> {
|
async setTurnOrder(order: BattlerIndex[]): Promise<void> {
|
||||||
await this.phaseInterceptor.to(TurnStartPhase, false);
|
await this.phaseInterceptor.to(TurnStartPhase, false);
|
||||||
|
|
||||||
vi.spyOn(this.scene.phaseManager.getCurrentPhase() as TurnStartPhase, "getSpeedOrder").mockReturnValue(order);
|
this.scene.phaseManager.dynamicQueueManager.setMoveOrder(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user