From ac9814e66544afd185b374b11c374dd16e1bdb6c Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Wed, 31 May 2023 15:04:03 -0400 Subject: [PATCH] Fix issues with targeting --- src/battle-phases.ts | 2 +- src/data/move.ts | 8 ++++---- src/ui/target-select-ui-handler.ts | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/battle-phases.ts b/src/battle-phases.ts index 9eb61b06d85..ba0f103cae2 100644 --- a/src/battle-phases.ts +++ b/src/battle-phases.ts @@ -570,7 +570,7 @@ export class SwitchSummonPhase extends SummonPhase { } preSummon(): void { - if (!this.doReturn || !this.scene.getParty()[this.slotIndex]) { + if (!this.doReturn || (this.slotIndex !== -1 && !this.scene.getParty()[this.slotIndex])) { this.switchAndSummon(); return; } diff --git a/src/data/move.ts b/src/data/move.ts index dc67c19c6e8..ab502749b95 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -1012,13 +1012,13 @@ export class HealAttr extends MoveEffectAttr { } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - this.addHealPhase(user, this.healRatio); + this.addHealPhase(this.selfTarget ? user : target, this.healRatio); return true; } - addHealPhase(user: Pokemon, healRatio: number) { - user.scene.unshiftPhase(new PokemonHealPhase(user.scene, user.getBattlerIndex(), - Math.max(Math.floor(user.getMaxHp() * healRatio), 1), getPokemonMessage(user, ' regained\nhealth!'), true, !this.showAnim)); + addHealPhase(target: Pokemon, healRatio: number) { + target.scene.unshiftPhase(new PokemonHealPhase(target.scene, target.getBattlerIndex(), + Math.max(Math.floor(target.getMaxHp() * healRatio), 1), getPokemonMessage(target, ' regained\nhealth!'), true, !this.showAnim)); } getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer { diff --git a/src/ui/target-select-ui-handler.ts b/src/ui/target-select-ui-handler.ts index 6195f799052..680b8585dd0 100644 --- a/src/ui/target-select-ui-handler.ts +++ b/src/ui/target-select-ui-handler.ts @@ -52,19 +52,19 @@ export default class TargetSelectUiHandler extends UiHandler { } else { switch (button) { case Button.UP: - if (this.cursor < BattlerIndex.ENEMY && this.targets.find(t => t >= BattlerIndex.ENEMY)) + if (this.cursor < BattlerIndex.ENEMY && this.targets.findIndex(t => t >= BattlerIndex.ENEMY) > -1) success = this.setCursor(this.targets.find(t => t >= BattlerIndex.ENEMY)); break; case Button.DOWN: - if (this.cursor >= BattlerIndex.ENEMY && this.targets.find(t => t < BattlerIndex.ENEMY)) + if (this.cursor >= BattlerIndex.ENEMY && this.targets.findIndex(t => t < BattlerIndex.ENEMY) > -1) success = this.setCursor(this.targets.find(t => t < BattlerIndex.ENEMY)); break; case Button.LEFT: - if (this.cursor % 2 && this.targets.find(t => t === this.cursor - 1)) + if (this.cursor % 2 && this.targets.findIndex(t => t === this.cursor - 1) > -1) success = this.setCursor(this.cursor - 1); break; case Button.RIGHT: - if (!(this.cursor % 2) && this.targets.find(t => t === this.cursor + 1)) + if (!(this.cursor % 2) && this.targets.findIndex(t => t === this.cursor + 1) > -1) success = this.setCursor(this.cursor + 1); break; }