mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-10-24 14:05:50 +02:00
* Move phase types out of phase interceptor * Create isXPhase method and add properties to each phase * Replace instanceof phase with isXPhase * Fix missing union types for phaseName * Update doc comment in phase.ts * Fix incomplete comment in encounter-phase * Make phaseName as public and fix more uses * Move phaseName property declaration before constructor in move anim phase Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Rename isXPhase to is --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
38 lines
999 B
TypeScript
38 lines
999 B
TypeScript
import { globalScene } from "#app/global-scene";
|
|
import { FieldPosition } from "#app/field/pokemon";
|
|
import { BattlePhase } from "./battle-phase";
|
|
|
|
export class ToggleDoublePositionPhase extends BattlePhase {
|
|
public readonly phaseName = "ToggleDoublePositionPhase";
|
|
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();
|
|
}
|
|
}
|
|
}
|