[Piece] Implement constructor and type and color getters

This commit is contained in:
2022-12-18 16:07:00 +01:00
parent dd7b9f009b
commit 8091771f62
2 changed files with 7 additions and 6 deletions

View File

@@ -2,10 +2,7 @@
#include <ostream>
Piece::Piece(PieceColor color, PieceType type)
{
(void)color;
(void)type;
Piece::Piece(PieceColor color, PieceType type) : _color(color), _type(type) {
}
Piece::Optional Piece::fromSymbol(char symbol) {
@@ -14,11 +11,11 @@ Piece::Optional Piece::fromSymbol(char symbol) {
}
PieceColor Piece::color() const {
return PieceColor::Black;
return _color;
}
PieceType Piece::type() const {
return PieceType::Pawn;
return _type;
}
bool operator==(const Piece &lhs, const Piece &rhs) {

View File

@@ -19,6 +19,10 @@ enum class PieceType {
};
class Piece {
const PieceColor _color;
const PieceType _type;
public:
using Optional = std::optional<Piece>;