2024-09-07 21:37:37 -07:00
|
|
|
import BattleScene from "#app/battle-scene";
|
|
|
|
import { BattlerIndex } from "#app/battle";
|
2024-11-03 01:04:20 -05:00
|
|
|
import { applyAbAttrs, applyPostDamageAbAttrs, BlockNonDirectDamageAbAttr, BlockStatusDamageAbAttr, PostDamageAbAttr, ReduceBurnDamageAbAttr } from "#app/data/ability";
|
2024-09-07 21:37:37 -07:00
|
|
|
import { CommonBattleAnim, CommonAnim } from "#app/data/battle-anims";
|
|
|
|
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 * as Utils from "#app/utils";
|
2024-08-19 03:23:52 +01:00
|
|
|
import { PokemonPhase } from "./pokemon-phase";
|
|
|
|
|
|
|
|
export class PostTurnStatusEffectPhase extends PokemonPhase {
|
|
|
|
constructor(scene: BattleScene, battlerIndex: BattlerIndex) {
|
|
|
|
super(scene, battlerIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
|
|
|
const pokemon = this.getPokemon();
|
|
|
|
if (pokemon?.isActive(true) && pokemon.status && pokemon.status.isPostTurn()) {
|
|
|
|
pokemon.status.incrementTurn();
|
|
|
|
const cancelled = new Utils.BooleanHolder(false);
|
|
|
|
applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled);
|
|
|
|
applyAbAttrs(BlockStatusDamageAbAttr, pokemon, cancelled);
|
|
|
|
|
|
|
|
if (!cancelled.value) {
|
|
|
|
this.scene.queueMessage(getStatusEffectActivationText(pokemon.status.effect, getPokemonNameWithAffix(pokemon)));
|
|
|
|
const damage = new Utils.NumberHolder(0);
|
|
|
|
switch (pokemon.status.effect) {
|
2024-10-19 18:44:36 -07:00
|
|
|
case StatusEffect.POISON:
|
|
|
|
damage.value = Math.max(pokemon.getMaxHp() >> 3, 1);
|
|
|
|
break;
|
|
|
|
case StatusEffect.TOXIC:
|
2024-10-22 09:37:13 -07:00
|
|
|
damage.value = Math.max(Math.floor((pokemon.getMaxHp() / 16) * pokemon.status.toxicTurnCount), 1);
|
2024-10-19 18:44:36 -07:00
|
|
|
break;
|
|
|
|
case StatusEffect.BURN:
|
|
|
|
damage.value = Math.max(pokemon.getMaxHp() >> 4, 1);
|
|
|
|
applyAbAttrs(ReduceBurnDamageAbAttr, pokemon, null, false, damage);
|
|
|
|
break;
|
2024-08-19 03:23:52 +01:00
|
|
|
}
|
|
|
|
if (damage.value) {
|
|
|
|
// Set preventEndure flag to avoid pokemon surviving thanks to focus band, sturdy, endure ...
|
|
|
|
this.scene.damageNumberHandler.add(this.getPokemon(), pokemon.damage(damage.value, false, true));
|
|
|
|
pokemon.updateInfo();
|
2024-11-03 01:04:20 -05:00
|
|
|
applyPostDamageAbAttrs(PostDamageAbAttr, pokemon, damage.value, pokemon.hasPassive(), false, []);
|
2024-08-19 03:23:52 +01:00
|
|
|
}
|
2024-09-13 09:46:22 -07:00
|
|
|
new CommonBattleAnim(CommonAnim.POISON + (pokemon.status.effect - 1), pokemon).play(this.scene, false, () => this.end());
|
2024-08-19 03:23:52 +01:00
|
|
|
} else {
|
|
|
|
this.end();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.end();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override end() {
|
|
|
|
if (this.scene.currentBattle.battleSpec === BattleSpec.FINAL_BOSS) {
|
|
|
|
this.scene.initFinalBossPhaseTwo(this.getPokemon());
|
|
|
|
} else {
|
|
|
|
super.end();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|