diff options
author | zedarider <ymherklotz@gmail.com> | 2017-01-13 23:19:00 +0000 |
---|---|---|
committer | zedarider <ymherklotz@gmail.com> | 2017-01-13 23:19:00 +0000 |
commit | 8320f7ec281891501a9b3092e20d990e7fd14700 (patch) | |
tree | f2ed38f470e74c491107743eac078f23e2e3aa9e /src/chess_piece.cpp | |
parent | eda873106d7f91214a4e4a32ee6b16889b248216 (diff) | |
download | ChessAI-8320f7ec281891501a9b3092e20d990e7fd14700.tar.gz ChessAI-8320f7ec281891501a9b3092e20d990e7fd14700.zip |
made it more object oriented but removed the board implementation
Diffstat (limited to 'src/chess_piece.cpp')
-rw-r--r-- | src/chess_piece.cpp | 61 |
1 files changed, 5 insertions, 56 deletions
diff --git a/src/chess_piece.cpp b/src/chess_piece.cpp index f73d4c1..8d4cb94 100644 --- a/src/chess_piece.cpp +++ b/src/chess_piece.cpp @@ -1,63 +1,12 @@ -#include "chess_ai.hpp" +#include "chess_piece.hpp" -chess_ai::chess_piece::chess_piece(piece_type type, piece_colour colour) : - type(type), colour(colour) { +using namespace ymhChessAI; - if(colour == black) { - y = 0; - } else { - y = 7; - } - if(type == king) { - x = 4; - } else { - x = 3; - } -} - -chess_ai::chess_piece::chess_piece(piece_type type, piece_colour colour, - unsigned x, unsigned y) : - type(type), colour(colour), x(x), y(y) {} - -chess_ai::chess_piece::~chess_piece() {} - -void chess_ai::chess_piece::set_type(piece_type type) { - this->type = type; -} - -void chess_ai::chess_piece::set_colour(piece_colour colour) { - this->colour = colour; -} - -void chess_ai::chess_piece::set_x(unsigned x) { - this->x = x; -} - -void chess_ai::chess_piece::set_y(unsigned y) { - this->y = y; -} +// Chess Piece Base class that all the pieces inherit from -void chess_ai::chess_piece::set(piece_type type, piece_colour colour, - unsigned x, unsigned y) { - set_type(type); - set_colour(colour); - set_x(x); - set_y(y); +ChessPiece::ChessPiece() : m_x(0), m_y(0) { } -std::string chess_ai::chess_piece::str() { - if(type == empty) - return " "; - else if(type == pawn) - return "p"; - else if(type == rook) - return "r"; - else if(type == knight) - return "n"; - else if(type == bishop) - return "b"; - else if(type == queen) - return "q"; - return "k"; +ChessPiece::ChessPiece(const int& x, const int& y) : m_x(x), m_y(y) { } |