From 22a2905cf860c08c13add0e6f9e0519a63281e2b Mon Sep 17 00:00:00 2001 From: Dean Date: Fri, 27 Dec 2024 14:47:34 -0800 Subject: [PATCH] Respect trick room in quash turn order --- src/data/move.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/data/move.ts b/src/data/move.ts index 0f7031d9d87..19ca18a914b 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -7670,7 +7670,7 @@ export class ForceLastAttr extends MoveEffectAttr { const targetMovePhase = target.scene.findPhase((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();