コード例 #1
0
ファイル: AbstractStrategy.php プロジェクト: Gtvar/Ticki
 /**
  * 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;
 }
コード例 #2
0
ファイル: SimpleStrategy.php プロジェクト: Gtvar/Ticki
 /**
  * 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];
 }