Add IsDead function to PlayerUnit (since HPPercent() <= 0 doesn't always mean player is dead due to int rounding error)

This commit is contained in:
adpist
2025-11-11 15:14:08 +01:00
committed by guiyomu-dev
parent 13f0b4d704
commit 51cf7b6a1f

View File

@@ -202,6 +202,11 @@ func (pu PlayerUnit) TotalPlayerGold() int {
return gold.Value + stashGold.Value
}
func (pu PlayerUnit) IsDead() bool {
life, _ := pu.FindStat(stat.Life, 0)
return life.Value <= 0
}
func (pu PlayerUnit) HPPercent() int {
life, _ := pu.FindStat(stat.Life, 0)
maxLife, _ := pu.FindStat(stat.MaxLife, 0)