Updated formatting to streamline as requested

Should handle logic better
This commit is contained in:
EmoUsedHM01 2024-04-13 19:06:13 +01:00 committed by GitHub
parent 56543b7eb9
commit 8369f5540c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2760,45 +2760,44 @@ export class PostTurnStatusEffectPhase extends PokemonPhase {
if (!cancelled.value) { if (!cancelled.value) {
this.scene.queueMessage(getPokemonMessage(pokemon, getStatusEffectActivationText(pokemon.status.effect))); this.scene.queueMessage(getPokemonMessage(pokemon, getStatusEffectActivationText(pokemon.status.effect)));
let healing: integer = 0; let netEffect = 0; // This variable now handles both healing and damage
let damage: integer = 0; const isHealing = pokemon.getAbility().id === Abilities.POISON_HEAL;
// Determine the amount of healing or damage based on the status effect
switch (pokemon.status.effect) { switch (pokemon.status.effect) {
case StatusEffect.POISON: case StatusEffect.POISON:
// If the Pokémon has the ability Poison Heal, heal instead of taking damage case StatusEffect.TOXIC:
if (pokemon.getAbility().id === Abilities.POISON_HEAL) if (isHealing) {
healing = Math.max(pokemon.getMaxHp() >> 3, 1); netEffect = Math.max(pokemon.getMaxHp() >> 3, 1); // Healing logic
else // Otherwise, take damage as usual } else {
damage = Math.max(pokemon.getMaxHp() >> 3, 1); // Toxic damage increases over time, Poison does not
netEffect = (pokemon.status.effect === StatusEffect.TOXIC) ?
Math.max(Math.floor((pokemon.getMaxHp() / 16) * pokemon.status.turnCount), 1) : // Applies if Toxic
Math.max(pokemon.getMaxHp() >> 3, 1); // Damage logic for Poison otherwise
}
break; break;
case StatusEffect.TOXIC: // Follow same logic from Poison, but with Toxic's damage formula case StatusEffect.BURN:
if (pokemon.getAbility().id === Abilities.POISON_HEAL) netEffect = Math.max(pokemon.getMaxHp() >> 4, 1); // Burn always causes damage
healing = Math.max(pokemon.getMaxHp() >> 3, 1);
else
damage = Math.max(Math.floor((pokemon.getMaxHp() / 16) * pokemon.status.turnCount), 1);
break;
case StatusEffect.BURN: // For the burn status effect, always take damage
damage = Math.max(pokemon.getMaxHp() >> 4, 1);
break; break;
} }
// Apply that healing or damage to the Pokémon's HP
if (healing > 0) { if (netEffect > 0) {
this.scene.damageNumberHandler.add(this.getPokemon(), pokemon.heal(healing), HitResult.HEAL); if (isHealing) {
new CommonBattleAnim(CommonAnim.POISON + (pokemon.status.effect - 1), pokemon).play(this.scene, () => this.end()); this.scene.damageNumberHandler.add(pokemon, pokemon.heal(netEffect), HitResult.HEAL);
pokemon.updateInfo(); } else {
} else if (damage > 0) { this.scene.damageNumberHandler.add(pokemon, pokemon.damage(netEffect));
this.scene.damageNumberHandler.add(this.getPokemon(), pokemon.damage(damage)); }
new CommonBattleAnim(CommonAnim.POISON + (pokemon.status.effect - 1), pokemon).play(this.scene, () => this.end());
const animType = CommonAnim.POISON + (pokemon.status.effect - 1);
new CommonBattleAnim(animType, pokemon).play(this.scene, () => this.end());
pokemon.updateInfo(); pokemon.updateInfo();
} else { } else {
// End the phase if the healing or damage is cancelled this.end(); // End the phase if no net effect to apply
this.end();
} }
} }
} else } else {
this.end(); this.end();
} }
}
} }
export class MessagePhase extends Phase { export class MessagePhase extends Phase {