Fixed eating

This commit is contained in:
PEMapModder
2016-02-11 15:42:07 +08:00
parent 52e8781d36
commit 28967ca495
5 changed files with 41 additions and 70 deletions

View File

@ -94,7 +94,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
}
public function getFood() : float{
return (float) $this->attributeMap->getAttribute(Attribute::HUNGER)->getValue();
return $this->attributeMap->getAttribute(Attribute::HUNGER)->getValue();
}
/**
@ -120,6 +120,10 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
}
}
public function getMaxFood() : float{
return $this->attributeMap->getAttribute(Attribute::HUNGER)->getMaxValue();
}
public function addFood(float $amount){
$attr = $this->attributeMap->getAttribute(Attribute::HUNGER);
$amount = max(min($amount, $attr->getMaxValue()), $attr->getMinValue());
@ -162,12 +166,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* Increases a human's exhaustion level.
* TODO walk per meter: 0.01
* TODO sneak per meter: 0.005
* TODO swim per meter: 0.015
* TODO sprint per meter: 0.1
* TODO jump: 0.2
* TODO regen per halfheart | food >= 18: 4.0
*
* @param float $amount
*/