Fixing moves.

This commit is contained in:
Alexander Huddleston 2015-10-27 14:49:03 -05:00
parent e969058b96
commit aa50abcaff

View file

@ -198,7 +198,7 @@ void Board::move(moves jugada){
int row = 8 - (jugada.row);
int column = charToIntColumn(jugada.column);
cout << row << " " << column << "\n\n";
//cout << row << " " << column << "\n\n";
if (row > 8 || row < 0 || column > 8 || column < 0) {
cout<<"ERROR: index out of bound."<<endl;
@ -206,6 +206,7 @@ void Board::move(moves jugada){
}
Piece* piece;
//cout << "TEST" << row << " " << column << "\n\n";
if (isPiece(row, column))
piece = getPiece(row, column);
@ -213,23 +214,23 @@ void Board::move(moves jugada){
cout<<"ERROR: attempting to move an invalid piece.\n";
return;
}
//cout << piece->getX() << piece->getY() << "\n\n";
if (piece->getType() != turn) {
cout<<"ERROR: attempting to move the wrong side's piece.\n";
}
else {
if (jugada.moveType == "FWD") {
if(isPiece(row--, column)) {
if(getPiece(row--, column)->getType() != piece->getType()) {
getPiece(row--, column)->isTaken();
piece->moveFwd();
if(piece->getType() == 'O') {
row--;
}
else {
row++;
}
if(isPiece(row, column)) {
cout << "Invalid move, there is a piece there.\n";
return;
}
}
else {
piece->moveFwd();
}