From 3161461b6c9960bc286c127f9f31ae609f4e3311 Mon Sep 17 00:00:00 2001 From: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Date: Mon, 5 May 2025 17:35:51 -0500 Subject: [PATCH] [Bug][UI/UX] Update battle-info inside pokemon#damageAndUpdate (#5778) * Update battle-info inside pokemon#damageAndUpdate * Ensure updatePokemonHp does not skip last hp number --- src/field/pokemon.ts | 5 +++++ src/ui/battle-info.ts | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index b9c64ad071c..5615f3844bd 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -4764,6 +4764,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { isIndirectDamage, ignoreFaintPhase, ); + // Ensure the battle-info bar's HP is updated, though only if the battle info is visible + // TODO: When battle-info UI is refactored, make this only update the HP bar + if (this.battleInfo.visible) { + this.updateInfo(); + } // Damage amount may have changed, but needed to be queued before calling damage function damagePhase.updateAmount(damage); /** diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index cabe897d7b6..839f0d62819 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -727,6 +727,12 @@ export default class BattleInfo extends Phaser.GameObjects.Container { }, onComplete: () => { updateHpFrame(); + // If, after tweening, the hp is different from the original (due to rounding), force the hp number display + // to update to the correct value. + if (this.player && this.lastHp !== pokemon.hp) { + this.setHpNumbers(pokemon.hp, pokemon.getMaxHp()); + this.lastHp = pokemon.hp; + } resolve(); }, });