pokerogue/src/phases/toggle-double-position-phase.ts
damocleas b41eee3c7f
Revert "[Refactor] Move many interfaces and enums to their own file" (#5661)
Revert "[Refactor] Move many interfaces and enums to their own file (#5646)"

This reverts commit c82e01eed3.
2025-04-14 12:28:36 -04:00

37 lines
940 B
TypeScript

import { globalScene } from "#app/global-scene";
import { FieldPosition } from "#app/field/pokemon";
import { BattlePhase } from "./battle-phase";
export class ToggleDoublePositionPhase extends BattlePhase {
private double: boolean;
constructor(double: boolean) {
super();
this.double = double;
}
start() {
super.start();
const playerPokemon = globalScene.getPlayerField().find(p => p.isActive(true));
if (playerPokemon) {
playerPokemon
.setFieldPosition(
this.double && globalScene.getPokemonAllowedInBattle().length > 1 ? FieldPosition.LEFT : FieldPosition.CENTER,
500,
)
.then(() => {
if (playerPokemon.getFieldIndex() === 1) {
const party = globalScene.getPlayerParty();
party[1] = party[0];
party[0] = playerPokemon;
}
this.end();
});
} else {
this.end();
}
}
}