Fix issues with targeting

This commit is contained in:
Flashfyre 2023-05-31 15:04:03 -04:00
parent 47fd9985c8
commit ac9814e665
3 changed files with 9 additions and 9 deletions

View File

@ -570,7 +570,7 @@ export class SwitchSummonPhase extends SummonPhase {
} }
preSummon(): void { preSummon(): void {
if (!this.doReturn || !this.scene.getParty()[this.slotIndex]) { if (!this.doReturn || (this.slotIndex !== -1 && !this.scene.getParty()[this.slotIndex])) {
this.switchAndSummon(); this.switchAndSummon();
return; return;
} }

View File

@ -1012,13 +1012,13 @@ export class HealAttr extends MoveEffectAttr {
} }
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { 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; return true;
} }
addHealPhase(user: Pokemon, healRatio: number) { addHealPhase(target: Pokemon, healRatio: number) {
user.scene.unshiftPhase(new PokemonHealPhase(user.scene, user.getBattlerIndex(), target.scene.unshiftPhase(new PokemonHealPhase(target.scene, target.getBattlerIndex(),
Math.max(Math.floor(user.getMaxHp() * healRatio), 1), getPokemonMessage(user, ' regained\nhealth!'), true, !this.showAnim)); Math.max(Math.floor(target.getMaxHp() * healRatio), 1), getPokemonMessage(target, ' regained\nhealth!'), true, !this.showAnim));
} }
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer { getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {

View File

@ -52,19 +52,19 @@ export default class TargetSelectUiHandler extends UiHandler {
} else { } else {
switch (button) { switch (button) {
case Button.UP: 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)); success = this.setCursor(this.targets.find(t => t >= BattlerIndex.ENEMY));
break; break;
case Button.DOWN: 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)); success = this.setCursor(this.targets.find(t => t < BattlerIndex.ENEMY));
break; break;
case Button.LEFT: 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); success = this.setCursor(this.cursor - 1);
break; break;
case Button.RIGHT: 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); success = this.setCursor(this.cursor + 1);
break; break;
} }