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:
@@ -202,6 +202,11 @@ func (pu PlayerUnit) TotalPlayerGold() int {
|
|||||||
return gold.Value + stashGold.Value
|
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 {
|
func (pu PlayerUnit) HPPercent() int {
|
||||||
life, _ := pu.FindStat(stat.Life, 0)
|
life, _ := pu.FindStat(stat.Life, 0)
|
||||||
maxLife, _ := pu.FindStat(stat.MaxLife, 0)
|
maxLife, _ := pu.FindStat(stat.MaxLife, 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user