From ae0504b451eb8591478c2ce319eb9e3739c32f31 Mon Sep 17 00:00:00 2001 From: Christopher Schmidt Date: Sun, 8 Sep 2024 11:41:06 -0400 Subject: [PATCH] Fixes metronome two turn moves for enemy pokemon --- src/field/pokemon.ts | 20 +++++++++++--------- src/phases/command-phase.ts | 4 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 6c2ebf05c29..2fa1d009ab9 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -4086,15 +4086,17 @@ export class EnemyPokemon extends Pokemon { */ getNextMove(): TurnMove { // If this Pokemon has a move already queued, return it. - const queuedMove = this.getMoveQueue().length - ? this.getMoveset().find(m => m?.moveId === this.getMoveQueue()[0].move) - : null; - if (queuedMove) { - if (queuedMove.isUsable(this, this.getMoveQueue()[0].ignorePP)) { - return { move: queuedMove.moveId, targets: this.getMoveQueue()[0].targets, ignorePP: this.getMoveQueue()[0].ignorePP }; - } else { - this.getMoveQueue().shift(); - return this.getNextMove(); + const moveQueue = this.getMoveQueue(); + if (moveQueue.length !== 0) { + const queuedMove = moveQueue[0]; + if (queuedMove) { + const moveIndex = this.getMoveset().findIndex(m => m?.moveId === moveQueue[0].move); + if ((moveIndex > -1 && this.getMoveset()[moveIndex]!.isUsable(this, queuedMove.ignorePP)) || queuedMove.virtual) { + return queuedMove; + } else { + this.getMoveQueue().shift(); + return this.getNextMove(); + } } } diff --git a/src/phases/command-phase.ts b/src/phases/command-phase.ts index 4855e516b7b..9295173f84a 100644 --- a/src/phases/command-phase.ts +++ b/src/phases/command-phase.ts @@ -55,7 +55,7 @@ export class CommandPhase extends FieldPhase { moveQueue.shift(); } - if (moveQueue.length) { + if (moveQueue.length !== 0) { const queuedMove = moveQueue[0]; if (!queuedMove.move) { this.handleCommand(Command.FIGHT, -1, false); @@ -63,7 +63,7 @@ export class CommandPhase extends FieldPhase { const moveIndex = playerPokemon.getMoveset().findIndex(m => m?.moveId === queuedMove.move); if (moveIndex > -1 && playerPokemon.getMoveset()[moveIndex]!.isUsable(playerPokemon, queuedMove.ignorePP)) { // TODO: is the bang correct? this.handleCommand(Command.FIGHT, moveIndex, queuedMove.ignorePP, { targets: queuedMove.targets, multiple: queuedMove.targets.length > 1 }); - } else if (moveQueue[0].virtual) { + } else if (queuedMove.virtual) { this.handleCommand(Command.FIGHT, moveIndex, queuedMove); } else { this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);