Exemple #1
0
 /**
  * Get a specific creature by its slug.
  *
  * @param  string  $slug
  * @return \Apolune\Contracts\Server\Creature
  */
 function creature_by_slug($slug)
 {
     $creatures = creatures();
     return head(array_where($creatures, function ($key, $creature) use($slug) {
         return strtolower($creature->slug()) === strtolower($slug);
     }));
 }
 /**
  * Retrieve the next creature.
  *
  * @param  \Apolune\Contracts\Server\Creature  $current
  * @return \Apolune\Contracts\Server\Creature|null
  */
 protected function nextCreature(Creature $current)
 {
     $result = null;
     $creatures = creatures();
     $creatures->each(function ($creature) use(&$result, $current) {
         if (!is_null($result)) {
             $result = $creature;
             return false;
         }
         if ($creature->slug() === $current->slug()) {
             $result = $creature;
         }
     });
     return $current->slug() === $creatures->last()->slug() ? null : $result;
 }