Ejemplo n.º 1
0
 public function isBug(SnakeBoard $board, $x, $y)
 {
     $bugs = $board->getBugs();
     for ($i = 0; $i < count($bugs); $i++) {
         if ($bugs[$i]->x == $x && $bugs[$i]->y == $y) {
             array_splice($bugs, $i, 1);
             $board->setBugs($bugs);
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
 public function moveSnakeModules(SnakeBoard $board, $sessionId, $direction)
 {
     $board->setPlayers($this->getPlayers());
     $board->setBugs($this->getBugs());
     $player = $this->getPlayer($sessionId);
     if (!$player) {
         return null;
     }
     if ($player->isInGame()) {
         $board->movePlayer($player, $direction);
         $this->saveBugs($board->getBugs());
         $this->savePlayer($sessionId, $player);
     } else {
         return false;
     }
 }