BUGFIX: Fix wrong HP after calling applyEntropy (#1313)

This commit is contained in:
catloversg 2024-05-29 02:15:12 +07:00 committed by GitHub
parent c2a56a6150
commit f439352438
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -6,6 +6,9 @@ import { updateGoMults } from "../../Go/effects/effect";
import type { PlayerObject } from "./PlayerObject";
export function applyEntropy(this: PlayerObject, stacks = 1): void {
// Save the current HP ratio.
const currentHpRatio = this.hp.current / this.hp.max;
// Re-apply all multipliers
this.reapplyAllAugmentations();
this.reapplyAllSourceFiles();
@ -13,4 +16,10 @@ export function applyEntropy(this: PlayerObject, stacks = 1): void {
this.mults = calculateEntropy(stacks);
staneksGift.updateMults();
updateGoMults();
/**
* The ratio of (hp.current / hp.max) may be wrong after multiple function calls above. We need to recalculate
* hp.current based on the saved value.
*/
this.hp.current = Math.round(this.hp.max * Math.min(currentHpRatio, 1));
}