mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-11-21 18:51:38 +01:00
* Initial changes for Synchronize ability * Fix psycho shift interaction causing buggy behaviour * Update to show ability even if opponent pokemon does not get statused * Fix some spacing * Update tests * Formatting change * Remove impossible `if` statement * Add `simulated` support * Apply suggestions from code review Co-authored-by: innerthunder <168692175+innerthunder@users.noreply.github.com> * Don't need those comments --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: innerthunder <168692175+innerthunder@users.noreply.github.com>
49 lines
2.2 KiB
TypeScript
49 lines
2.2 KiB
TypeScript
import BattleScene from "#app/battle-scene";
|
|
import { BattlerIndex } from "#app/battle";
|
|
import { CommonBattleAnim, CommonAnim } from "#app/data/battle-anims";
|
|
import { getStatusEffectObtainText, getStatusEffectOverlapText } from "#app/data/status-effect";
|
|
import { StatusEffect } from "#app/enums/status-effect";
|
|
import Pokemon from "#app/field/pokemon";
|
|
import { getPokemonNameWithAffix } from "#app/messages";
|
|
import { PokemonPhase } from "./pokemon-phase";
|
|
import { PostTurnStatusEffectPhase } from "./post-turn-status-effect-phase";
|
|
|
|
export class ObtainStatusEffectPhase extends PokemonPhase {
|
|
private statusEffect?: StatusEffect | undefined;
|
|
private cureTurn?: integer | null;
|
|
private sourceText?: string | null;
|
|
private sourcePokemon?: Pokemon | null;
|
|
|
|
constructor(scene: BattleScene, battlerIndex: BattlerIndex, statusEffect?: StatusEffect, cureTurn?: integer | null, sourceText?: string | null, sourcePokemon?: Pokemon | null) {
|
|
super(scene, battlerIndex);
|
|
|
|
this.statusEffect = statusEffect;
|
|
this.cureTurn = cureTurn;
|
|
this.sourceText = sourceText;
|
|
this.sourcePokemon = sourcePokemon; // For tracking which Pokemon caused the status effect
|
|
}
|
|
|
|
start() {
|
|
const pokemon = this.getPokemon();
|
|
if (pokemon && !pokemon.status) {
|
|
if (pokemon.trySetStatus(this.statusEffect, false, this.sourcePokemon)) {
|
|
if (this.cureTurn) {
|
|
pokemon.status!.cureTurn = this.cureTurn; // TODO: is this bang correct?
|
|
}
|
|
pokemon.updateInfo(true);
|
|
new CommonBattleAnim(CommonAnim.POISON + (this.statusEffect! - 1), pokemon).play(this.scene, false, () => {
|
|
this.scene.queueMessage(getStatusEffectObtainText(this.statusEffect, getPokemonNameWithAffix(pokemon), this.sourceText ?? undefined));
|
|
if (pokemon.status?.isPostTurn()) {
|
|
this.scene.pushPhase(new PostTurnStatusEffectPhase(this.scene, this.battlerIndex));
|
|
}
|
|
this.end();
|
|
});
|
|
return;
|
|
}
|
|
} else if (pokemon.status?.effect === this.statusEffect) {
|
|
this.scene.queueMessage(getStatusEffectOverlapText(this.statusEffect ?? StatusEffect.NONE, getPokemonNameWithAffix(pokemon)));
|
|
}
|
|
this.end();
|
|
}
|
|
}
|