mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-04-19 03:55:13 -04:00
29 lines
968 B
TypeScript
29 lines
968 B
TypeScript
import { globalScene } from "#app/global-scene";
|
|
import { BattlerIndex } from "#app/battle";
|
|
import type Pokemon from "#app/field/pokemon";
|
|
import { FieldPhase } from "./field-phase";
|
|
|
|
export abstract class PokemonPhase extends FieldPhase {
|
|
protected battlerIndex: BattlerIndex | number;
|
|
public player: boolean;
|
|
public fieldIndex: number;
|
|
|
|
constructor(battlerIndex?: BattlerIndex | number) {
|
|
super();
|
|
|
|
if (battlerIndex === undefined) {
|
|
battlerIndex = globalScene.getField().find(p => p?.isActive())!.getBattlerIndex(); // TODO: is the bang correct here?
|
|
}
|
|
|
|
this.battlerIndex = battlerIndex;
|
|
this.player = battlerIndex < 2;
|
|
this.fieldIndex = battlerIndex % 2;
|
|
}
|
|
|
|
getPokemon(): Pokemon {
|
|
if (this.battlerIndex > BattlerIndex.ENEMY_2) {
|
|
return globalScene.getPokemonById(this.battlerIndex)!; //TODO: is this bang correct?
|
|
}
|
|
return globalScene.getField()[this.battlerIndex]!; //TODO: is this bang correct?
|
|
}
|
|
}
|