Exemple #1
0
 public function heal(BeeInterface $bee, HoneyPoolInterface $pool)
 {
     if (!$pool->takeHoney(self::HEAL_COST)) {
         return false;
     }
     return $bee->setLifespan($bee->getLifespan() + self::HEAL_VALUE);
 }
Exemple #2
0
 public function addBee(BeeInterface $bee)
 {
     if ($bee->getType() != BeeTypesInterface::BEE_TYPE_QUEEN) {
         $this->bees[] = $bee;
         end($this->bees);
         $bee->setId(key($this->bees));
         reset($this->bees);
         return true;
     }
     if (!empty($this->queen)) {
         throw new FullPoolByTypeException("Can't add 2 queens", 550);
     }
     $this->bees[] = $bee;
     end($this->bees);
     $this->queen = key($this->bees);
     $bee->setId($this->queen);
     reset($this->bees);
     return true;
 }