Start searching from front of phaseQueue instead of weather

This commit is contained in:
Dean 2024-12-27 11:35:07 -08:00
parent f81c713380
commit fadc2e526d

View File

@ -40,7 +40,6 @@ import { GameMode } from "#app/game-mode";
import { applyChallenges, ChallengeType } from "./challenge"; import { applyChallenges, ChallengeType } from "./challenge";
import { SwitchType } from "#enums/switch-type"; import { SwitchType } from "#enums/switch-type";
import { StatusEffect } from "enums/status-effect"; import { StatusEffect } from "enums/status-effect";
import { WeatherEffectPhase } from "#app/phases/weather-effect-phase";
export enum MoveCategory { export enum MoveCategory {
PHYSICAL, PHYSICAL,
@ -7670,13 +7669,13 @@ export class ForceLastAttr extends MoveEffectAttr {
override apply(user: Pokemon, target: Pokemon, _move: Move, _args: any[]): boolean { override apply(user: Pokemon, target: Pokemon, _move: Move, _args: any[]): boolean {
const targetMovePhase = target.scene.findPhase<MovePhase>((phase) => phase.pokemon === target); const targetMovePhase = target.scene.findPhase<MovePhase>((phase) => phase.pokemon === target);
if (targetMovePhase && target.scene.tryRemovePhase((phase: MovePhase) => phase.pokemon === target)) { if (targetMovePhase && target.scene.tryRemovePhase((phase: MovePhase) => phase.pokemon === target)) {
const weatherPhase = target.scene.findPhase((phase) => phase instanceof WeatherEffectPhase)!; let newMovePhaseIndex = 1;
let newMovePhaseIndex = target.scene.phaseQueue.indexOf(weatherPhase); let nextMovePhase = target.scene.phaseQueue[newMovePhaseIndex];
let nextMovePhase = target.scene.phaseQueue[newMovePhaseIndex - 1]; // Search until a slower quashed move or end of turn is found
// Means that a speed tie will go in "order quashed" - need to see if this is the case (it's prob random)
while (nextMovePhase instanceof MovePhase while (nextMovePhase instanceof MovePhase
&& nextMovePhase.isForcedLast() && (!nextMovePhase.isForcedLast() || nextMovePhase.pokemon.getEffectiveStat(Stat.SPD) >= user.getEffectiveStat(Stat.SPD))) {
&& nextMovePhase.pokemon.getEffectiveStat(Stat.SPD) < user.getEffectiveStat(Stat.SPD)) { newMovePhaseIndex++;
newMovePhaseIndex--;
nextMovePhase = target.scene.phaseQueue[newMovePhaseIndex]; nextMovePhase = target.scene.phaseQueue[newMovePhaseIndex];
} }
target.scene.phaseQueue.splice(newMovePhaseIndex, 0, new MovePhase(target.scene, target, [ ...targetMovePhase.targets ], targetMovePhase.move, false, false, true)); target.scene.phaseQueue.splice(newMovePhaseIndex, 0, new MovePhase(target.scene, target, [ ...targetMovePhase.targets ], targetMovePhase.move, false, false, true));