Update running away in Double Battles (#1336)

* Add check for active pokemon and double battle with 1 active

* remove unecessary case
This commit is contained in:
Matthew 2024-05-24 19:46:52 -04:00 committed by GitHub
parent 416d666b30
commit 5e7a9b0872
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2156,13 +2156,21 @@ export class TurnStartPhase extends FieldPhase {
this.scene.unshiftPhase(new AttemptCapturePhase(this.scene, turnCommand.targets[0] % 2, turnCommand.cursor)); this.scene.unshiftPhase(new AttemptCapturePhase(this.scene, turnCommand.targets[0] % 2, turnCommand.cursor));
break; break;
case Command.POKEMON: case Command.POKEMON:
this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, pokemon.getFieldIndex(), turnCommand.cursor, true, turnCommand.args[0] as boolean, pokemon.isPlayer()));
case Command.RUN: case Command.RUN:
const isSwitch = turnCommand.command === Command.POKEMON; let runningPokemon = pokemon;
if (isSwitch) { if (this.scene.currentBattle.double) {
this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, pokemon.getFieldIndex(), turnCommand.cursor, true, turnCommand.args[0] as boolean, pokemon.isPlayer())); const playerActivePokemon = field.filter(pokemon => pokemon.isPlayer() && pokemon.isActive());
} else { // if only one pokemon is alive, use that one
this.scene.unshiftPhase(new AttemptRunPhase(this.scene, pokemon.getFieldIndex())); if (playerActivePokemon.length > 1) {
// find which active pokemon has faster speed
const fasterPokemon = playerActivePokemon[0].getStat(Stat.SPD) > playerActivePokemon[1].getStat(Stat.SPD) ? playerActivePokemon[0] : playerActivePokemon[1];
// check if either active pokemon has the ability "Run Away"
const hasRunAway = playerActivePokemon.find(p => p.hasAbility(Abilities.RUN_AWAY));
runningPokemon = hasRunAway !== undefined ? hasRunAway : fasterPokemon;
}
} }
this.scene.unshiftPhase(new AttemptRunPhase(this.scene, runningPokemon.getFieldIndex()));
break; break;
} }
} }