Human: beware negative values in addXp()

This commit is contained in:
Dylan K. Taylor 2020-10-16 20:42:13 +01:00
parent 1fe4fdc67c
commit 42171f6e06

View File

@ -400,7 +400,9 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
* @param bool $playSound Whether to play level-up and XP gained sounds.
*/
public function addXp(int $amount, bool $playSound = true) : bool{
$this->totalXp += $amount;
if($amount > 0){
$this->totalXp += $amount;
}
$oldLevel = $this->getXpLevel();
$oldTotal = $this->getCurrentTotalXp();