pokerogue/src/phases/common-anim-phase.ts
Sirz Benjie 408b66f913
[Misc][Refactor][GitHub] Ditch eslint for biome, and add a formatter (#5495)
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-03-09 14:13:25 -07:00

34 lines
1.1 KiB
TypeScript

import type { BattlerIndex } from "#app/battle";
import { globalScene } from "#app/global-scene";
import type { CommonAnim } from "#app/data/battle-anims";
import { CommonBattleAnim } from "#app/data/battle-anims";
import { PokemonPhase } from "./pokemon-phase";
export class CommonAnimPhase extends PokemonPhase {
private anim: CommonAnim | null;
private targetIndex: number | undefined;
private playOnEmptyField: boolean;
constructor(battlerIndex?: BattlerIndex, targetIndex?: BattlerIndex, anim?: CommonAnim, playOnEmptyField = false) {
super(battlerIndex);
this.anim = anim!; // TODO: is this bang correct?
this.targetIndex = targetIndex;
this.playOnEmptyField = playOnEmptyField;
}
setAnimation(anim: CommonAnim) {
this.anim = anim;
}
start() {
const target =
this.targetIndex !== undefined
? (this.player ? globalScene.getEnemyField() : globalScene.getPlayerField())[this.targetIndex]
: this.getPokemon();
new CommonBattleAnim(this.anim, this.getPokemon(), target).play(false, () => {
this.end();
});
}
}