Respect trick room in quash turn order

This commit is contained in:
Dean 2024-12-27 14:47:34 -08:00
parent c1f6303260
commit 22a2905cf8
1 changed files with 6 additions and 1 deletions

View File

@ -7670,7 +7670,7 @@ export class ForceLastAttr extends MoveEffectAttr {
const targetMovePhase = target.scene.findPhase<MovePhase>((phase) => phase.pokemon === target);
if (targetMovePhase && target.scene.tryRemovePhase((phase: MovePhase) => phase.pokemon === target)) {
const prependPhase = target.scene.findPhase((phase) => [ MovePhase, MoveEndPhase ].every(cls => !(phase instanceof cls))
|| (phase instanceof MovePhase) && (phase.isForcedLast() && phase.pokemon.getEffectiveStat(Stat.SPD) < target.getEffectiveStat(Stat.SPD)));
|| (phase instanceof MovePhase) && phaseForcedSlower(phase, target, !!target.scene.arena.getTag(ArenaTagType.TRICK_ROOM)));
if (prependPhase) {
target.scene.phaseQueue.splice(target.scene.phaseQueue.indexOf(prependPhase), 0, new MovePhase(target.scene, target, [ ...targetMovePhase.targets ], targetMovePhase.move, false, false, true));
}
@ -7679,6 +7679,11 @@ export class ForceLastAttr extends MoveEffectAttr {
}
}
const phaseForcedSlower = (phase: MovePhase, target: Pokemon, trickRoom: boolean): boolean => {
const faster = !trickRoom ? phase.pokemon.getEffectiveStat(Stat.SPD) < target.getEffectiveStat(Stat.SPD) : phase.pokemon.getEffectiveStat(Stat.SPD) > target.getEffectiveStat(Stat.SPD);
return phase.isForcedLast() && faster;
};
const failOnGravityCondition: MoveConditionFunc = (user, target, move) => !user.scene.arena.getTag(ArenaTagType.GRAVITY);
const failOnBossCondition: MoveConditionFunc = (user, target, move) => !target.isBossImmune();