/** * {@inheritdoc} */ public function possibleMovesFrom($position, BoardInterface $board, $filtered = true, $allowKingCapture = false) { if (!$board->getGame()) { throw new \InvalidArgumentException('Can\'t calculate possible moves if the board is not connected to a game'); } $piece = $board->getSquare($position)->getPiece(); if ($piece === null) { throw new \InvalidArgumentException(sprintf('There is no piece to move from that position: %s', $position)); } $walker = new BoardWalker($board, $piece->getColor(), $position, $allowKingCapture); $piece->configureWalker($walker, $board->getGame()); $moves = $walker->flush(); if ($filtered === true) { $moves = $this->applyChecks($moves, $piece->getColor(), $board); } return $moves; }