pokerogue/src/phases/tera-phase.ts
Sirz Benjie 93745f14b7
[Refactor] Decouple phase system from battle-scene (#5953)
* Move phase logic into its own class

* Move ts ignore comment
2025-06-07 17:59:30 -07:00

55 lines
1.6 KiB
TypeScript

import type Pokemon from "#app/field/pokemon";
import { getPokemonNameWithAffix } from "#app/messages";
import { BattlePhase } from "./battle-phase";
import i18next from "i18next";
import { globalScene } from "#app/global-scene";
import { PokemonType } from "#enums/pokemon-type";
import { achvs } from "#app/system/achv";
import { SpeciesFormChangeTeraTrigger } from "#app/data/pokemon-forms";
import { CommonAnim, CommonBattleAnim } from "#app/data/battle-anims";
export class TeraPhase extends BattlePhase {
public readonly phaseName = "TeraPhase";
public pokemon: Pokemon;
constructor(pokemon: Pokemon) {
super();
this.pokemon = pokemon;
}
start() {
super.start();
globalScene.phaseManager.queueMessage(
i18next.t("battle:pokemonTerastallized", {
pokemonNameWithAffix: getPokemonNameWithAffix(this.pokemon),
type: i18next.t(`pokemonInfo:Type.${PokemonType[this.pokemon.getTeraType()]}`),
}),
);
new CommonBattleAnim(CommonAnim.TERASTALLIZE, this.pokemon).play(false, () => {
this.end();
});
}
end() {
this.pokemon.isTerastallized = true;
this.pokemon.updateSpritePipelineData();
if (this.pokemon.isPlayer()) {
globalScene.arena.playerTerasUsed += 1;
}
globalScene.triggerPokemonFormChange(this.pokemon, SpeciesFormChangeTeraTrigger);
if (this.pokemon.isPlayer()) {
globalScene.validateAchv(achvs.TERASTALLIZE);
if (this.pokemon.getTeraType() === PokemonType.STELLAR) {
globalScene.validateAchv(achvs.STELLAR_TERASTALLIZE);
}
}
super.end();
}
}