From 4716585d5acb45b00960eebb4f8ae4580e580da0 Mon Sep 17 00:00:00 2001 From: zedarider Date: Sat, 5 Nov 2016 12:49:32 +0000 Subject: adding initial files --- src/chess_piece.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/chess_piece.cpp (limited to 'src/chess_piece.cpp') diff --git a/src/chess_piece.cpp b/src/chess_piece.cpp new file mode 100644 index 0000000..cd28ef8 --- /dev/null +++ b/src/chess_piece.cpp @@ -0,0 +1,66 @@ +#include "../include/chess_ai.hpp" + +chess_ai::chess_piece::chess_piece() { + type = empty; + colour = none; + x = -1; + y = -1; +} + +chess_ai::chess_piece::chess_piece(piece_type type, piece_colour colour) { + this->type = type; + this->colour = colour; + + 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) { + this->type = type; + this->colour = colour; + this->x = x; + this->y = y; + +} + +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; +} + +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"; +} -- cgit