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

View File

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