#ifndef CHESS_ENGINE_PIECE_HPP #define CHESS_ENGINE_PIECE_HPP #include #include enum class PieceColor { White = 0x0, Black = 0x1, }; enum class PieceType { Pawn = 2, Knight, Bishop, Rook, Queen, King }; std::ostream &operator<<(std::ostream &os, const PieceType &pt); class Piece { public: constexpr static const PieceType PromotionTypes[4] = {PieceType::Knight, PieceType::Bishop, PieceType::Rook, PieceType::Queen}; using Optional = std::optional; Piece(PieceColor color, PieceType type); static Optional fromSymbol(char symbol); static char toSymbol(PieceType type); static std::optional pieceTypeFromSymbol(char symbol); PieceColor color() const; PieceType type() const; char toSymbol() const; private: const PieceColor mColor; const PieceType mType; }; bool operator==(const Piece &lhs, const Piece &rhs); std::ostream &operator<<(std::ostream &os, const Piece &piece); // Invert a color (White becomes Black and vice versa) PieceColor operator!(PieceColor color); #endif