[Bug][UI/UX] Update battle-info inside pokemon#damageAndUpdate (#5778)

* Update battle-info inside pokemon#damageAndUpdate

* Ensure updatePokemonHp does not skip last hp number
This commit is contained in:
Sirz Benjie 2025-05-05 17:35:51 -05:00 committed by GitHub
parent 92f1cfdd50
commit 3161461b6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -4764,6 +4764,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
isIndirectDamage, isIndirectDamage,
ignoreFaintPhase, 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 // Damage amount may have changed, but needed to be queued before calling damage function
damagePhase.updateAmount(damage); damagePhase.updateAmount(damage);
/** /**

View File

@ -727,6 +727,12 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
}, },
onComplete: () => { onComplete: () => {
updateHpFrame(); 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(); resolve();
}, },
}); });