pokerogue/src/phases/common-anim-phase.ts
NightKev 1e6ceb5581
[Misc] Clean up various phases (part 1) (#4797)
* Clean up various phases

Remove redundant code, utilize default parameters,
clean up some leftover `strict-null` `TODO`s,
replace `integer` with `number`

* Replace `* as Utils` imports with named imports

* Apply Biome
2025-04-06 03:10:52 +00:00

39 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?: BattlerIndex;
private playOnEmptyField: boolean;
constructor(
battlerIndex?: BattlerIndex,
targetIndex?: BattlerIndex,
anim: CommonAnim | null = null,
playOnEmptyField = false,
) {
super(battlerIndex);
this.anim = anim;
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();
});
}
}