From 4b1f979af2dc54c2222b746a6460208c29e35595 Mon Sep 17 00:00:00 2001 From: Reldnahc Date: Sat, 4 May 2024 17:33:46 -0500 Subject: [PATCH] properly handle targets on mutli moves. also checks which pokemon did the bouncing. --- src/phases.ts | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index aeba4fbef..59bb70ed1 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2410,19 +2410,24 @@ export class MoveEffectPhase extends PokemonPhase { let isBounced: BattlerTag | boolean = false; for (let opponent of targets) { - isBounced = this.move.getMove().hasFlag(MoveFlags.MAGIC_COAT_MOVE) && (targets[0].findTags(t => t instanceof BounceTag).find(t => targets[0].lapseTag(t.tagType)) || opponent.hasAbilityWithAttr(MagicBounceAbAttr)); + isBounced = this.move.getMove().hasFlag(MoveFlags.MAGIC_COAT_MOVE) && (opponent.findTags(t => t instanceof BounceTag).find(t => opponent.lapseTag(t.tagType)) || opponent.hasAbilityWithAttr(MagicBounceAbAttr)); if (isBounced) { - this.scene.queueMessage(getPokemonMessage(targets[0], '\nbounced the move back!')); + this.scene.queueMessage(getPokemonMessage(opponent, '\nbounced the move back!')); const tempTargets = targets; - this.targets = getMoveTargets(tempTargets[0], this.move.moveId).targets; - targets = []; - for (let index of this.targets){ - const target = this.scene.getField()[index]; - if (target) - targets.push(target); + if (this.move.getMove().isMultiTarget()){ + this.targets = getMoveTargets(tempTargets[0], this.move.moveId).targets; + targets = []; + for (let index of this.targets){ + const target = this.scene.getField()[index]; + if (target) + targets.push(target); + } + } else { + this.targets = [user.getBattlerIndex()]; + targets = [user]; } user = tempTargets[0]; - if (!this.move.getMove().applyConditions(user, targets[0], this.move.getMove())) { + if (!this.move.getMove().applyConditions(user, opponent, this.move.getMove())) { this.scene.queueMessage(i18next.t('menu:attackFailed')); return this.end(); }