[Board] Refactor and implement makeMove
This commit is contained in:
27
Piece.hpp
27
Piece.hpp
@@ -5,17 +5,17 @@
|
||||
#include <iosfwd>
|
||||
|
||||
enum class PieceColor {
|
||||
White = 0,
|
||||
Black = 1,
|
||||
White = 0x0,
|
||||
Black = 0x1,
|
||||
};
|
||||
|
||||
enum class PieceType {
|
||||
Pawn = 0b000,
|
||||
Knight = 0b010,
|
||||
Bishop = 0b100,
|
||||
Rook = 0b110,
|
||||
Queen = 0b1000,
|
||||
King = 0b1010
|
||||
Pawn = 2,
|
||||
Knight,
|
||||
Bishop,
|
||||
Rook,
|
||||
Queen,
|
||||
King
|
||||
};
|
||||
|
||||
class Piece {
|
||||
@@ -27,26 +27,15 @@ public:
|
||||
Piece(PieceColor color, PieceType type);
|
||||
|
||||
static Optional fromSymbol(char symbol);
|
||||
static Optional fromValue(unsigned value);
|
||||
|
||||
static std::optional<PieceType> pieceTypeFromSymbol(char symbol);
|
||||
|
||||
PieceColor color() const;
|
||||
PieceType type() const;
|
||||
int colorVal() const;
|
||||
int typeVal() const;
|
||||
|
||||
private:
|
||||
const PieceColor mColor;
|
||||
const PieceType mType;
|
||||
|
||||
static inline PieceColor valToColor(unsigned v) {
|
||||
return static_cast<PieceColor>(v % 2);
|
||||
}
|
||||
|
||||
static inline PieceType valToType(unsigned v) {
|
||||
return static_cast<PieceType>(v - (v % 2));
|
||||
}
|
||||
};
|
||||
|
||||
bool operator==(const Piece &lhs, const Piece &rhs);
|
||||
|
Reference in New Issue
Block a user