示例#1
0
文件: Cell.php 项目: Gtvar/Ticki
 /**
  * Construct
  *
  * @param $position
  * @param $type
  */
 public function __construct($position, $type)
 {
     $this->position = $position;
     if (!in_array($type, array(self::TIC, self::TAC))) {
         throw ExceptionFactory::wrongCellException($type);
     }
     $this->type = $type;
 }
示例#2
0
文件: TicTac.php 项目: Gtvar/Ticki
 /**
  * One step
  *
  * @param $type
  * @param $position
  *
  * @throws Exception\WrongCellException
  */
 public function step($type, $position)
 {
     switch ($type) {
         case Cell::TIC:
             $cell = Cell::createTic($position);
             break;
         case Cell::TAC:
             $cell = Cell::createTac($position);
             break;
         default:
             throw ExceptionFactory::wrongCellException($type);
             break;
     }
     // Human step
     $this->board->addCell($cell);
     if ($this->board->isFinish()) {
         return;
     }
     // Strategy step
     $cell = $this->strategy->getCell($this->board, $this->oppositeType);
     $this->board->addCell($cell);
 }