[Piece] Add fromValue
This commit is contained in:
@@ -27,6 +27,7 @@ public:
|
||||
Piece(PieceColor color, PieceType type);
|
||||
|
||||
static Optional fromSymbol(char symbol);
|
||||
static Optional fromValue(unsigned value);
|
||||
|
||||
static std::optional<PieceType> pieceTypeFromSymbol(char symbol);
|
||||
|
||||
@@ -38,6 +39,14 @@ public:
|
||||
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