Files
cpl_cpp-project/Piece.hpp
2022-12-18 17:25:08 +01:00

46 lines
796 B
C++

#ifndef CHESS_ENGINE_PIECE_HPP
#define CHESS_ENGINE_PIECE_HPP
#include <optional>
#include <iosfwd>
enum class PieceColor {
White = 0,
Black = 1,
};
enum class PieceType {
Pawn = 'P',
Knight = 'N',
Bishop = 'B',
Rook = 'R',
Queen = 'Q',
King = 'K'
};
class Piece {
public:
using Optional = std::optional<Piece>;
Piece(PieceColor color, PieceType type);
static Optional fromSymbol(char symbol);
PieceColor color() const;
PieceType type() 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