[Bug] Fix 2-turn/charging moves breaking on lack of targets (#6759)

This commit is contained in:
Bertie690 2025-11-06 23:27:07 -05:00 committed by GitHub
parent a0aa25ab75
commit d8d5c12bbc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 0 deletions

View File

@ -509,6 +509,9 @@ export class MovePhase extends PokemonPhase {
) {
this.showFailedText();
this.fail();
// clear out 2 turn moves
// TODO: Make a helper for this atp
this.pokemon.getMoveQueue().shift();
this.pokemon.pushMoveHistory(this.moveHistoryEntry);
return true;
}

View File

@ -131,4 +131,26 @@ describe("Moves - Dig", () => {
expect(postDigEarthquakeDmg).toBeGreaterThanOrEqual(2 * preDigEarthquakeDmg);
expect(postDigEarthquakeDmg).toBeLessThan(2 * (preDigEarthquakeDmg + 1));
});
it("should not softlock when used against a dying enemy 2 in Doubles", async () => {
game.override.battleStyle("double");
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
const feebas = game.field.getPlayerPokemon();
const enemy2 = game.scene.getEnemyField()[1];
// use dig and make the targeted enemy faint post charge
game.move.use(MoveId.DIG, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2);
await game.toEndOfTurn();
await game.killPokemon(enemy2);
await game.phaseInterceptor.to("CommandPhase");
expect(feebas.getMoveQueue()[0]?.targets).toEqual([BattlerIndex.ENEMY_2]);
expect(enemy2).toHaveFainted();
await game.toEndOfTurn();
// TODO: Does this redirect to the other enemy?
expect(feebas.getMoveQueue()).toHaveLength(0);
});
});