From 8320f7ec281891501a9b3092e20d990e7fd14700 Mon Sep 17 00:00:00 2001 From: zedarider Date: Fri, 13 Jan 2017 23:19:00 +0000 Subject: made it more object oriented but removed the board implementation --- src/chess_piece.cpp | 61 +++++------------------------------------------------ 1 file changed, 5 insertions(+), 56 deletions(-) (limited to 'src/chess_piece.cpp') 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) { } -- cgit