mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 00:52:47 +02:00
68 lines
2.8 KiB
TypeScript
68 lines
2.8 KiB
TypeScript
import { globalScene } from "#app/global-scene";
|
|
import type { BattlerIndex } from "#enums/battler-index";
|
|
import { applyAbAttrs } from "#app/data/abilities/apply-ab-attrs";
|
|
import { CommonBattleAnim } from "#app/data/battle-anims";
|
|
import { CommonAnim } from "#enums/move-anims-common";
|
|
import { getStatusEffectActivationText } from "#app/data/status-effect";
|
|
import { BattleSpec } from "#app/enums/battle-spec";
|
|
import { StatusEffect } from "#app/enums/status-effect";
|
|
import { getPokemonNameWithAffix } from "#app/messages";
|
|
import { BooleanHolder, NumberHolder } from "#app/utils/common";
|
|
import { PokemonPhase } from "./pokemon-phase";
|
|
|
|
export class PostTurnStatusEffectPhase extends PokemonPhase {
|
|
public readonly phaseName = "PostTurnStatusEffectPhase";
|
|
// biome-ignore lint/complexity/noUselessConstructor: Not unnecessary as it makes battlerIndex required
|
|
constructor(battlerIndex: BattlerIndex) {
|
|
super(battlerIndex);
|
|
}
|
|
|
|
start() {
|
|
const pokemon = this.getPokemon();
|
|
if (pokemon?.isActive(true) && pokemon.status && pokemon.status.isPostTurn() && !pokemon.switchOutStatus) {
|
|
pokemon.status.incrementTurn();
|
|
const cancelled = new BooleanHolder(false);
|
|
applyAbAttrs("BlockNonDirectDamageAbAttr", { pokemon, cancelled });
|
|
applyAbAttrs("BlockStatusDamageAbAttr", { pokemon, cancelled });
|
|
|
|
if (!cancelled.value) {
|
|
globalScene.phaseManager.queueMessage(
|
|
getStatusEffectActivationText(pokemon.status.effect, getPokemonNameWithAffix(pokemon)),
|
|
);
|
|
const damage = new NumberHolder(0);
|
|
switch (pokemon.status.effect) {
|
|
case StatusEffect.POISON:
|
|
damage.value = Math.max(pokemon.getMaxHp() >> 3, 1);
|
|
break;
|
|
case StatusEffect.TOXIC:
|
|
damage.value = Math.max(Math.floor((pokemon.getMaxHp() / 16) * pokemon.status.toxicTurnCount), 1);
|
|
break;
|
|
case StatusEffect.BURN:
|
|
damage.value = Math.max(pokemon.getMaxHp() >> 4, 1);
|
|
applyAbAttrs("ReduceBurnDamageAbAttr", { pokemon, burnDamage: damage });
|
|
break;
|
|
}
|
|
if (damage.value) {
|
|
// Set preventEndure flag to avoid pokemon surviving thanks to focus band, sturdy, endure ...
|
|
globalScene.damageNumberHandler.add(this.getPokemon(), pokemon.damage(damage.value, false, true));
|
|
pokemon.updateInfo();
|
|
applyAbAttrs("PostDamageAbAttr", { pokemon, damage: damage.value });
|
|
}
|
|
new CommonBattleAnim(CommonAnim.POISON + (pokemon.status.effect - 1), pokemon).play(false, () => this.end());
|
|
} else {
|
|
this.end();
|
|
}
|
|
} else {
|
|
this.end();
|
|
}
|
|
}
|
|
|
|
override end() {
|
|
if (globalScene.currentBattle.battleSpec === BattleSpec.FINAL_BOSS) {
|
|
globalScene.initFinalBossPhaseTwo(this.getPokemon());
|
|
} else {
|
|
super.end();
|
|
}
|
|
}
|
|
}
|