aboutsummaryrefslogtreecommitdiffstats
path: root/src/chess_piece.cpp
diff options
context:
space:
mode:
authorzedarider <ymherklotz@gmail.com>2016-11-05 12:49:32 +0000
committerzedarider <ymherklotz@gmail.com>2016-11-05 12:49:32 +0000
commit4716585d5acb45b00960eebb4f8ae4580e580da0 (patch)
treece5caa0fed7216ba83f8a8ac979807b332b6f3ce /src/chess_piece.cpp
parent146e32f222be037993fd4d1ab6148eda6c895d08 (diff)
downloadChessAI-4716585d5acb45b00960eebb4f8ae4580e580da0.tar.gz
ChessAI-4716585d5acb45b00960eebb4f8ae4580e580da0.zip
adding initial files
Diffstat (limited to 'src/chess_piece.cpp')
-rw-r--r--src/chess_piece.cpp66
1 files changed, 66 insertions, 0 deletions
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";
+}