Fixed counter move logic using inverted conditional

This commit is contained in:
Bertie690 2025-06-24 18:19:15 -04:00
parent 1018e1f7ff
commit cd25df2491

View File

@ -586,6 +586,7 @@ export class MovePhase extends BattlePhase {
*
* If there is no last attacker or they are no longer on the field, a message is displayed and the
* move is marked for failure.
* @todo Make this a feature of the move rather than basing logic on {@linkcode BattlerIndex.ATTACKER}
*/
protected resolveCounterAttackTarget(): void {
if (this.targets.length !== 1 || this.targets[0] !== BattlerIndex.ATTACKER) {
@ -594,6 +595,12 @@ export class MovePhase extends BattlePhase {
// TODO: This should be covered in move conditions
if (this.pokemon.turnData.attacksReceived.length === 0) {
this.fail();
this.showMoveText();
this.showFailedText();
return;
}
this.targets[0] = this.pokemon.turnData.attacksReceived[0].sourceBattlerIndex;
// account for metal burst and comeuppance hitting remaining targets in double battles
@ -608,13 +615,6 @@ export class MovePhase extends BattlePhase {
}
}
if (this.targets[0] === BattlerIndex.ATTACKER) {
this.fail();
this.showMoveText();
this.showFailedText();
}
}
/**
* Handles the case where the move was cancelled or failed:
* - Uses PP if the move failed (not cancelled) and should use PP (failed moves are not affected by {@linkcode AbilityId.PRESSURE | Pressure})