properly handle targets on mutli moves. also checks which pokemon did the bouncing.

pull/468/head
Reldnahc 2024-05-04 17:33:46 -05:00
parent 1e28f95453
commit 4b1f979af2
1 changed files with 14 additions and 9 deletions

View File

@ -2410,10 +2410,11 @@ export class MoveEffectPhase extends PokemonPhase {
let isBounced: BattlerTag | boolean = false; let isBounced: BattlerTag | boolean = false;
for (let opponent of targets) { 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) { if (isBounced) {
this.scene.queueMessage(getPokemonMessage(targets[0], '\nbounced the move back!')); this.scene.queueMessage(getPokemonMessage(opponent, '\nbounced the move back!'));
const tempTargets = targets; const tempTargets = targets;
if (this.move.getMove().isMultiTarget()){
this.targets = getMoveTargets(tempTargets[0], this.move.moveId).targets; this.targets = getMoveTargets(tempTargets[0], this.move.moveId).targets;
targets = []; targets = [];
for (let index of this.targets){ for (let index of this.targets){
@ -2421,8 +2422,12 @@ export class MoveEffectPhase extends PokemonPhase {
if (target) if (target)
targets.push(target); targets.push(target);
} }
} else {
this.targets = [user.getBattlerIndex()];
targets = [user];
}
user = tempTargets[0]; 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')); this.scene.queueMessage(i18next.t('menu:attackFailed'));
return this.end(); return this.end();
} }