mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-29 21:12:45 +02:00
61 lines
2.5 KiB
TypeScript
61 lines
2.5 KiB
TypeScript
import { globalScene } from "#app/global-scene";
|
|
import type { BattlerIndex } from "#enums/battler-index";
|
|
import { CommonBattleAnim } from "#app/data/battle-anims";
|
|
import { CommonAnim } from "#enums/move-anims-common";
|
|
import { getStatusEffectObtainText, getStatusEffectOverlapText } from "#app/data/status-effect";
|
|
import { StatusEffect } from "#app/enums/status-effect";
|
|
import type Pokemon from "#app/field/pokemon";
|
|
import { getPokemonNameWithAffix } from "#app/messages";
|
|
import { PokemonPhase } from "./pokemon-phase";
|
|
import { SpeciesFormChangeStatusEffectTrigger } from "#app/data/pokemon-forms/form-change-triggers";
|
|
import { applyPostSetStatusAbAttrs } from "#app/data/abilities/apply-ab-attrs";
|
|
import { isNullOrUndefined } from "#app/utils/common";
|
|
|
|
export class ObtainStatusEffectPhase extends PokemonPhase {
|
|
public readonly phaseName = "ObtainStatusEffectPhase";
|
|
|
|
constructor(
|
|
battlerIndex: BattlerIndex,
|
|
private statusEffect: StatusEffect,
|
|
private turnsRemaining = 0,
|
|
private sourceText: string | null = null,
|
|
private sourcePokemon: Pokemon | null = null,
|
|
) {
|
|
super(battlerIndex);
|
|
}
|
|
|
|
start() {
|
|
const pokemon = this.getPokemon();
|
|
if (pokemon && !pokemon.status) {
|
|
if (pokemon.trySetStatus(this.statusEffect, false, this.sourcePokemon)) {
|
|
if (this.turnsRemaining) {
|
|
pokemon.status!.sleepTurnsRemaining = this.turnsRemaining;
|
|
}
|
|
pokemon.updateInfo(true);
|
|
new CommonBattleAnim(CommonAnim.POISON + (this.statusEffect! - 1), pokemon).play(false, () => {
|
|
globalScene.phaseManager.queueMessage(
|
|
getStatusEffectObtainText(
|
|
this.statusEffect,
|
|
getPokemonNameWithAffix(pokemon),
|
|
this.sourceText ?? undefined,
|
|
),
|
|
);
|
|
if (!isNullOrUndefined(this.statusEffect) && this.statusEffect !== StatusEffect.FAINT) {
|
|
globalScene.triggerPokemonFormChange(pokemon, SpeciesFormChangeStatusEffectTrigger, true);
|
|
// If mold breaker etc was used to set this status, it shouldn't apply to abilities activated afterwards
|
|
globalScene.arena.setIgnoreAbilities(false);
|
|
applyPostSetStatusAbAttrs("PostSetStatusAbAttr", pokemon, this.statusEffect, this.sourcePokemon);
|
|
}
|
|
this.end();
|
|
});
|
|
return;
|
|
}
|
|
} else if (pokemon.status?.effect === this.statusEffect) {
|
|
globalScene.phaseManager.queueMessage(
|
|
getStatusEffectOverlapText(this.statusEffect ?? StatusEffect.NONE, getPokemonNameWithAffix(pokemon)),
|
|
);
|
|
}
|
|
this.end();
|
|
}
|
|
}
|