mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-01-31 05:07:11 +00:00
update running away in double battles for real this time (#1345)
This commit is contained in:
parent
564add66d2
commit
623c05a3df
@ -2156,13 +2156,22 @@ 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:
|
||||||
case Command.RUN:
|
|
||||||
const isSwitch = turnCommand.command === Command.POKEMON;
|
|
||||||
if (isSwitch) {
|
|
||||||
this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, pokemon.getFieldIndex(), turnCommand.cursor, true, turnCommand.args[0] as boolean, pokemon.isPlayer()));
|
this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, pokemon.getFieldIndex(), turnCommand.cursor, true, turnCommand.args[0] as boolean, pokemon.isPlayer()));
|
||||||
} else {
|
break;
|
||||||
this.scene.unshiftPhase(new AttemptRunPhase(this.scene, pokemon.getFieldIndex()));
|
case Command.RUN:
|
||||||
|
let runningPokemon = pokemon;
|
||||||
|
if (this.scene.currentBattle.double) {
|
||||||
|
const playerActivePokemon = field.filter(pokemon => pokemon.isPlayer() && pokemon.isActive());
|
||||||
|
// if only one pokemon is alive, use that one
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user