Queue faint phases only after all other phases

This commit is contained in:
Sirz Benjie 2025-05-12 18:16:23 -05:00
parent 9b1a222935
commit 88d38f7891
No known key found for this signature in database
GPG Key ID: 4A524B4D196C759E

View File

@ -98,6 +98,8 @@ export class MoveEffectPhase extends PokemonPhase {
/** Is this the last strike of a move? */
private lastHit: boolean;
private faintPhases: FaintPhase[] = [];
/** Phases queued during moves */
private queuedPhases: Phase[] = [];
@ -243,6 +245,11 @@ export class MoveEffectPhase extends PokemonPhase {
throw new Error("Unexpected hit check result");
}
}
// Append the faint phases after resolving all move effects so that the faint phase happens after any message phases
if (this.faintPhases.length) {
globalScene.unshiftPhase(...this.faintPhases);
}
}
public override start(): void {
@ -900,7 +907,7 @@ export class MoveEffectPhase extends PokemonPhase {
// set splice index here, so future scene queues happen before FaintedPhase
globalScene.setPhaseQueueSplice();
globalScene.unshiftPhase(new FaintPhase(target.getBattlerIndex(), false, user));
this.faintPhases.push(new FaintPhase(target.getBattlerIndex(), false, user));
target.destroySubstitute();
target.lapseTag(BattlerTagType.COMMANDED);