diff options
-rw-r--r-- | src/pawn.cpp | 18 |
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) { - } } } |