mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-10-23 21:45:50 +02:00
* Update `battle-scene.ts` and `data/field/pokemon.ts` `battle-scene.ts` changes: - `getParty()` renamed to `getPlayerParty()` for clarity - `getNonSwitchedXPokemon()` consolidated into `getXPokemon()` - Some tsdocs were added/updated for `getXParty()`, `getXField()` and `getXPokemon()`; and those functions were explicitly marked as `public` - Helper function `getPokemonAllowedInBattle()` added `pokemon.ts` changes: - `isAllowed()` renamed to `isAllowedInChallenge()` for clarity - A redundant check for an active scene is removed in `isActive()` - Some tsdocs were added/updated for `isFainted()`, `isAllowedInChallenge()`, `isAllowedInBattle()` and `isActive()`; and those functions were explicitly marked as `public` - `isFainted()` now checks for `hp <= 0` instead of `!hp` Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Backport eslint change to reduce merge conflicts * Fix merge issues --------- Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: Tempoanon <163687446+Tempo-anon@users.noreply.github.com>
32 lines
895 B
TypeScript
32 lines
895 B
TypeScript
import BattleScene from "#app/battle-scene";
|
|
import { FieldPosition } from "#app/field/pokemon";
|
|
import { BattlePhase } from "./battle-phase";
|
|
|
|
export class ToggleDoublePositionPhase extends BattlePhase {
|
|
private double: boolean;
|
|
|
|
constructor(scene: BattleScene, double: boolean) {
|
|
super(scene);
|
|
|
|
this.double = double;
|
|
}
|
|
|
|
start() {
|
|
super.start();
|
|
|
|
const playerPokemon = this.scene.getPlayerField().find(p => p.isActive(true));
|
|
if (playerPokemon) {
|
|
playerPokemon.setFieldPosition(this.double && this.scene.getPokemonAllowedInBattle().length > 1 ? FieldPosition.LEFT : FieldPosition.CENTER, 500).then(() => {
|
|
if (playerPokemon.getFieldIndex() === 1) {
|
|
const party = this.scene.getPlayerParty();
|
|
party[1] = party[0];
|
|
party[0] = playerPokemon;
|
|
}
|
|
this.end();
|
|
});
|
|
} else {
|
|
this.end();
|
|
}
|
|
}
|
|
}
|