/** * Just put first free cell on board */ public function getCell(Board $board, $type) { $free = $board->getFreeCell(); if (empty($free)) { ExceptionFactory::runtime("Not have free cells"); } $position = $this->getPosition($board, $type); switch ($type) { case Cell::TIC: $cell = Cell::createTic($position); break; default: $cell = Cell::createTac($position); } return $cell; }
/** * Get new random position for free cells * * @param Board $board * @param $type * * @return int */ protected function getPosition(Board $board, $type) { $free = $board->getFreeCell(); return $free[0]; }