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 {
// 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();
}
}
}

View File

@ -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);