Fixes metronome two turn moves for enemy pokemon

This commit is contained in:
Christopher Schmidt 2024-09-08 11:41:06 -04:00
parent bfef09ecb3
commit ae0504b451
2 changed files with 13 additions and 11 deletions

View File

@ -4086,15 +4086,17 @@ export class EnemyPokemon extends Pokemon {
*/ */
getNextMove(): TurnMove { getNextMove(): TurnMove {
// If this Pokemon has a move already queued, return it. // If this Pokemon has a move already queued, return it.
const queuedMove = this.getMoveQueue().length const moveQueue = this.getMoveQueue();
? this.getMoveset().find(m => m?.moveId === this.getMoveQueue()[0].move) if (moveQueue.length !== 0) {
: null; const queuedMove = moveQueue[0];
if (queuedMove) { if (queuedMove) {
if (queuedMove.isUsable(this, this.getMoveQueue()[0].ignorePP)) { const moveIndex = this.getMoveset().findIndex(m => m?.moveId === moveQueue[0].move);
return { move: queuedMove.moveId, targets: this.getMoveQueue()[0].targets, ignorePP: this.getMoveQueue()[0].ignorePP }; if ((moveIndex > -1 && this.getMoveset()[moveIndex]!.isUsable(this, queuedMove.ignorePP)) || queuedMove.virtual) {
} else { return queuedMove;
this.getMoveQueue().shift(); } else {
return this.getNextMove(); this.getMoveQueue().shift();
return this.getNextMove();
}
} }
} }

View File

@ -55,7 +55,7 @@ export class CommandPhase extends FieldPhase {
moveQueue.shift(); moveQueue.shift();
} }
if (moveQueue.length) { if (moveQueue.length !== 0) {
const queuedMove = moveQueue[0]; const queuedMove = moveQueue[0];
if (!queuedMove.move) { if (!queuedMove.move) {
this.handleCommand(Command.FIGHT, -1, false); 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); 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? 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 }); 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); this.handleCommand(Command.FIGHT, moveIndex, queuedMove);
} else { } else {
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex); this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);