/** * {@inheritdoc} */ public function __construct(PlayerInterface $whitePlayer, PlayerInterface $blackPlayer, BoardInterface $board, $id = null) { if ($whitePlayer->getColor() !== Color::WHITE) { throw new \LogicException("Given white player's PlayerInterface should have a white color"); } if ($blackPlayer->getColor() !== Color::BLACK) { throw new \LogicException("Given black player's PlayerInterface should have a black color"); } $board->setGame($this); $this->whitePlayer = $whitePlayer; $this->blackPlayer = $blackPlayer; $this->board = $board; $this->id = $id ?: uniqid(); $this->states = new ArrayCollection(); }
/** * @param PlayerInterface $player * * @return array */ private function getExpectedPlayerArray(PlayerInterface $player) { return ['color' => $player->getColor(), 'name' => $player->getName(), 'captures' => $this->getExpectedCapturesArray($player->getCaptures()->toArray()), 'human' => $player->isHuman()]; }