Exemple #1
0
 /**
  * Returns available hexes info.
  * @return array
  */
 public function getAvailableHexesInfo()
 {
     $data = [];
     foreach ($this->_available_hexes as $available) {
         $data[] = Hex::create($available);
     }
     return $data;
 }
Exemple #2
0
 /**
  * Puts hex on the board.
  * @param integer $hexOrder
  * @param string $hexPosition
  */
 public function placeHex($hexOrder, $hexPosition)
 {
     $hero = $this->getHero();
     if (in_array($hero->getStage(), [Player::STAGE_HEX_GIVEN, Player::STAGE_HEX_SET_EMPTY, Player::STAGE_HEX_SET_SYSTEM])) {
         $available_hexes = $hero->getAvailableHexes();
         if (!empty($available_hexes[$hexOrder])) {
             $position = $this->decodeHexLocation($hexPosition);
             $emptyHexes = $this->getBoard()->getAvailablePieces();
             foreach ($emptyHexes as $e) {
                 if ($e[0] === $position[0] && $e[1] === $position[1]) {
                     $newHex = Hex::create($available_hexes[$hexOrder]);
                     $newHex->setXY($position);
                     $this->getBoard()->getHexes()->add($newHex);
                     $rest_available_hexes = [];
                     foreach ($available_hexes as $order => $ah) {
                         if ($order != $hexOrder) {
                             $rest_available_hexes[] = $ah;
                         }
                     }
                     $hero->setAvailableHexes($rest_available_hexes);
                     $hero->setStage(Player::STAGE_HEX_SET_SYSTEM);
                     $this->postCommand();
                     break;
                 }
             }
         }
     }
 }