28 lines
1.1 KiB
C++

#include "Rook.hpp"
/**
* Creates a new rook with a specified color and position.
* @param color The color of the rook.
* @param position The position of the rook.
*/
Rook::Rook(ChessPieceColor color, ChessPiecePosition position) : ChessPiece(color, position) {
this->_char = this->_CHAR_ROOK;
this->_unicode = {"\u265C", "\u2656"};
}
/**
* Gets all chess piece positions the rook can move next.
* It is also possible to ignore several chess pieces while the next positions are calculated.
* @param chessboard A pointer to the chessboard.
* @param ignore A set of chess piece positions to be ignored.
* @return A set of chess piece positions the rook can move next.
*/
std::set<ChessPiecePosition> Rook::GetNextPositions(Chessboard* chessboard, std::set<ChessPiecePosition> ignore) {
// 3.3 The rook may move to any square along the file or the rank on which it stands.
std::set<ChessPiecePosition> positions;
positions.merge(this->GetFilePositions(chessboard, ignore));
positions.merge(this->GetRankPositions(chessboard, ignore));
return positions;
}