aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorymherklotz <ymherklotz@gmail.com>2017-01-25 13:22:29 +0000
committerymherklotz <ymherklotz@gmail.com>2017-01-25 13:22:29 +0000
commit4e79ea68d54305e6705a3a8e83a730508b9f1c1b (patch)
tree30ddf1e2561db1ff02d2d9ba0d2a7c12c387b89e
parent7ec074f67ae29a792e718fc48f7817b3a77b81ad (diff)
downloadChessAI-4e79ea68d54305e6705a3a8e83a730508b9f1c1b.tar.gz
ChessAI-4e79ea68d54305e6705a3a8e83a730508b9f1c1b.zip
Starting movement of the pawnfinish_chess_piece
-rw-r--r--src/pawn.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/pawn.cpp b/src/pawn.cpp
index 458b980..5c5f1f6 100644
--- a/src/pawn.cpp
+++ b/src/pawn.cpp
@@ -7,13 +7,19 @@
*
* -----------------------------------------------------------------------------
*
- * Pawn class implementation
+ * Pawn class implementation, checking if there is a piece in the way of the
+ * one that is currently moving will be the chess boards concern
+ *
+ * Update: Checking if a piece is in the way will be the concern of this class
+ * because the move function has to perform the whole move.
*
*/
#include "chess_piece.hpp"
#include "chess_constants.hpp"
+#include <cmath>
+
using namespace ymhChessAI;
@@ -24,11 +30,15 @@ Pawn::Pawn(const int& x, const int& y, const Colour& colour) : ChessPiece(x, y,
}
void Pawn::move(const int& x, const int& y) {
+ int move_length = y - (int)m_y;
+
+ // First check what colour the pawn is
if(m_colour == Colour::White) {
- if(m_y == ChessConstants::WHITE_PAWN_ROW) {
+ // if this condition is met the pawn can move
+ if(move_length == -2 && m_y == ChessConstants::WHITE_PAWN_ROW) {
+ // we now have to check if there is a piece in between the pawn and
+ // it's desination
}
} else {
- if(m_y == ChessConstants::BLACK_PAWN_ROW) {
- }
}
}