mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-12-14 05:45:20 +01:00
* Add abilityAttr.is methods * [WIP] move modifier stuff around * Untangle circular deps from modifiers * Move unlockables to own file * Untangle all circular deps outside of MEs * Move constants in MEs to their own files * Re-add missing import to battle.ts * Add necessary overload for getTag * Add missing type import in weather.ts * Init modifier types and pools in loading-scene * Remove stray commented code * Apply kev's suggestions from code review Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
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, applyPostDamageAbAttrs } 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, null, false, 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();
|
|
applyPostDamageAbAttrs("PostDamageAbAttr", pokemon, damage.value, pokemon.hasPassive(), false, []);
|
|
}
|
|
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();
|
|
}
|
|
}
|
|
}
|