mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 17:12:44 +02:00
Ensure that zero/negative priority activations happen after postsummonphase
This commit is contained in:
parent
aca6d2ce8d
commit
07646feabe
@ -3,6 +3,8 @@ import type { Phase } from "#app/phase";
|
|||||||
import { ActivatePriorityQueuePhase } from "#app/phases/activate-priority-queue-phase";
|
import { ActivatePriorityQueuePhase } from "#app/phases/activate-priority-queue-phase";
|
||||||
import { type PostSummonPhase, PostSummonActivateAbilityPhase } from "#app/phases/post-summon-phase";
|
import { type PostSummonPhase, PostSummonActivateAbilityPhase } from "#app/phases/post-summon-phase";
|
||||||
import { Stat } from "#enums/stat";
|
import { Stat } from "#enums/stat";
|
||||||
|
import { BooleanHolder } from "#app/utils";
|
||||||
|
import { TrickRoomTag } from "#app/data/arena-tag";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores a list of {@linkcode Phase}s
|
* Stores a list of {@linkcode Phase}s
|
||||||
@ -46,7 +48,10 @@ export class PostSummonPhasePriorityQueue extends PhasePriorityQueue {
|
|||||||
public override reorder(): void {
|
public override reorder(): void {
|
||||||
this.queue.sort((phaseA: PostSummonPhase, phaseB: PostSummonPhase) => {
|
this.queue.sort((phaseA: PostSummonPhase, phaseB: PostSummonPhase) => {
|
||||||
if (phaseA.getPriority() === phaseB.getPriority()) {
|
if (phaseA.getPriority() === phaseB.getPriority()) {
|
||||||
return phaseB.getPokemon().getEffectiveStat(Stat.SPD) - phaseA.getPokemon().getEffectiveStat(Stat.SPD);
|
return (
|
||||||
|
(phaseB.getPokemon().getEffectiveStat(Stat.SPD) - phaseA.getPokemon().getEffectiveStat(Stat.SPD)) *
|
||||||
|
(isTrickRoom() ? -1 : 1)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return phaseB.getPriority() - phaseA.getPriority();
|
return phaseB.getPriority() - phaseA.getPriority();
|
||||||
@ -66,7 +71,8 @@ export class PostSummonPhasePriorityQueue extends PhasePriorityQueue {
|
|||||||
const phasePokemon = phase.getPokemon();
|
const phasePokemon = phase.getPokemon();
|
||||||
|
|
||||||
phasePokemon.getAbilityPriorities().forEach(priority => {
|
phasePokemon.getAbilityPriorities().forEach(priority => {
|
||||||
this.queue.push(new PostSummonActivateAbilityPhase(phasePokemon.getBattlerIndex(), priority));
|
// Treat all activation phases of zero or lower priority as one stage lower to ensure that they activate after the normal PostSummonPhase
|
||||||
|
this.queue.push(new PostSummonActivateAbilityPhase(phasePokemon.getBattlerIndex(), priority - +(priority <= 0)));
|
||||||
globalScene.appendToPhase(
|
globalScene.appendToPhase(
|
||||||
new ActivatePriorityQueuePhase(DynamicPhaseType.POST_SUMMON),
|
new ActivatePriorityQueuePhase(DynamicPhaseType.POST_SUMMON),
|
||||||
ActivatePriorityQueuePhase,
|
ActivatePriorityQueuePhase,
|
||||||
@ -76,6 +82,12 @@ export class PostSummonPhasePriorityQueue extends PhasePriorityQueue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isTrickRoom(): boolean {
|
||||||
|
const speedReversed = new BooleanHolder(false);
|
||||||
|
globalScene.arena.applyTags(TrickRoomTag, false, speedReversed);
|
||||||
|
return speedReversed.value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum representation of the phase types held by implementations of {@linkcode PhasePriorityQueue}
|
* Enum representation of the phase types held by implementations of {@linkcode PhasePriorityQueue}
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user