diff --git a/Board.cpp b/Board.cpp index 44900bf..44e5ee9 100755 --- a/Board.cpp +++ b/Board.cpp @@ -94,6 +94,15 @@ void Board::changeTurns(){ } void Board::displayBoard(){ + /* + cout << "Debugging:\n"; + for (int i = 0; i < pieces.size(); ++i){ + if(i%8 == 0) + cout << "\n"; + cout << pieces[i]->getX() << " " << pieces[i]->getY() << " " << pieces[i]->getType() << "\t"; + } + cout << "Debugging:\n\n"; + */ cout << "; A B C D E F G H"< 8 || row < 0 || column > 8 || column < 0) { cout<<"ERROR: index out of bound."<moveFwd(); + if(isPiece(row--, column)) { + if(getPiece(row--, column)->getType() != piece->getType()) { + getPiece(row--, column)->isTaken(); + piece->moveFwd(); + } + else { + cout << "Invalid move, there is a piece there.\n"; + return; + } + } + else { + piece->moveFwd(); + } } else if (jugada.moveType == "LEFT") { //add error checking - piece->moveLeft(); + if(isPiece(row--, column--)) { + if(getPiece(row--, column--)->getType() != piece->getType()) { + getPiece(row--, column--)->isTaken(); + piece->moveLeft(); + } + else { + cout << "Invalid move, there is a piece there.\n"; + return; + } + } + else { + piece->moveLeft(); + } } else if (jugada.moveType == "RIGHT") { //add error checking - piece->moveRight(); + if(isPiece(row--, column++)) { + if(getPiece(row--, column++)->getType() != piece->getType()) { + getPiece(row--, column++)->isTaken(); + piece->moveRight(); + } + else { + cout << "Invalid move, there is a piece there.\n"; + return; + } + } + else { + piece->moveRight(); + } } } } diff --git a/Engine.cpp b/Engine.cpp index 4a83431..9e12925 100755 --- a/Engine.cpp +++ b/Engine.cpp @@ -41,6 +41,8 @@ void Engine::startGame(){ b->changeTurns(); } + cout << "TEST\n\n"; + while(b->getTurn() == 'X' ) { easyAI(); diff --git a/Piece.cpp b/Piece.cpp index 6796826..a223740 100755 --- a/Piece.cpp +++ b/Piece.cpp @@ -65,5 +65,5 @@ void Piece::moveRight(){ } void Piece::isTaken(){ - // + cout << getX() << " " << getY() << "\n\n"; } \ No newline at end of file