fix: limit hp/pp to their max value

This commit is contained in:
Kazhnuz 2021-07-03 13:18:16 +02:00
parent 4c46e510d0
commit 109ed7c9b2

View file

@ -51,6 +51,7 @@ function AbstractMobParent:setHP(newHP, relative)
if (self.hp == 0) then
self:die()
end
self.hp = math.min(self.hp, self.stats:get(self.stats.HPMAX))
end
function AbstractMobParent:setPP(newPP, relative)
@ -60,6 +61,7 @@ function AbstractMobParent:setPP(newPP, relative)
self.pp = newPP
end
self.pp = math.floor(math.max(0, self.pp))
self.pp = math.min(self.pp, self.stats:get(self.stats.PPMAX))
end
function AbstractMobParent:getStats()