diff --git a/src/queues/dynamic-queue-manager.ts b/src/queues/dynamic-queue-manager.ts index c140c8bcc9e..edd2afa35f6 100644 --- a/src/queues/dynamic-queue-manager.ts +++ b/src/queues/dynamic-queue-manager.ts @@ -55,15 +55,18 @@ export class DynamicQueueManager { } public setMoveTimingModifier(condition: PhaseConditionFunc, modifier: MovePhaseTimingModifier) { - const movePhaseQueue: MovePhasePriorityQueue = this.dynamicPhaseMap.get("MovePhase") as MovePhasePriorityQueue; - movePhaseQueue.setTimingModifier(condition, modifier); + this.getMovePhaseQueue().setTimingModifier(condition, modifier); } public setMoveForPhase(condition: PhaseConditionFunc, move: PokemonMove) { - (this.dynamicPhaseMap.get("MovePhase") as MovePhasePriorityQueue).setMoveForPhase(condition, move); + this.getMovePhaseQueue().setMoveForPhase(condition, move); } public setMoveOrder(order: BattlerIndex[]) { - (this.dynamicPhaseMap.get("MovePhase") as MovePhasePriorityQueue).setMoveOrder(order); + this.getMovePhaseQueue().setMoveOrder(order); + } + + private getMovePhaseQueue(): MovePhasePriorityQueue { + return this.dynamicPhaseMap.get("MovePhase") as MovePhasePriorityQueue; } } diff --git a/src/queues/move-phase-priority-queue.ts b/src/queues/move-phase-priority-queue.ts index 81ec1120156..dd01fcbb210 100644 --- a/src/queues/move-phase-priority-queue.ts +++ b/src/queues/move-phase-priority-queue.ts @@ -30,6 +30,11 @@ export class MovePhasePriorityQueue extends PokemonPhasePriorityQueue this.setOrder = order; } + public override clear(): void { + this.setOrder = undefined; + super.clear(); + } + private sortPostSpeed(): void { this.queue.sort((a: MovePhase, b: MovePhase) => { const priority = [a, b].map(movePhase => {