Fixing moves.
This commit is contained in:
parent
e969058b96
commit
aa50abcaff
1 changed files with 12 additions and 11 deletions
23
Board.cpp
23
Board.cpp
|
@ -198,7 +198,7 @@ void Board::move(moves jugada){
|
||||||
int row = 8 - (jugada.row);
|
int row = 8 - (jugada.row);
|
||||||
int column = charToIntColumn(jugada.column);
|
int column = charToIntColumn(jugada.column);
|
||||||
|
|
||||||
cout << row << " " << column << "\n\n";
|
//cout << row << " " << column << "\n\n";
|
||||||
|
|
||||||
if (row > 8 || row < 0 || column > 8 || column < 0) {
|
if (row > 8 || row < 0 || column > 8 || column < 0) {
|
||||||
cout<<"ERROR: index out of bound."<<endl;
|
cout<<"ERROR: index out of bound."<<endl;
|
||||||
|
@ -206,6 +206,7 @@ void Board::move(moves jugada){
|
||||||
}
|
}
|
||||||
|
|
||||||
Piece* piece;
|
Piece* piece;
|
||||||
|
//cout << "TEST" << row << " " << column << "\n\n";
|
||||||
if (isPiece(row, column))
|
if (isPiece(row, column))
|
||||||
piece = getPiece(row, column);
|
piece = getPiece(row, column);
|
||||||
|
|
||||||
|
@ -213,22 +214,22 @@ void Board::move(moves jugada){
|
||||||
cout<<"ERROR: attempting to move an invalid piece.\n";
|
cout<<"ERROR: attempting to move an invalid piece.\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//cout << piece->getX() << piece->getY() << "\n\n";
|
||||||
if (piece->getType() != turn) {
|
if (piece->getType() != turn) {
|
||||||
cout<<"ERROR: attempting to move the wrong side's piece.\n";
|
cout<<"ERROR: attempting to move the wrong side's piece.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
if (jugada.moveType == "FWD") {
|
if (jugada.moveType == "FWD") {
|
||||||
if(isPiece(row--, column)) {
|
if(piece->getType() == 'O') {
|
||||||
if(getPiece(row--, column)->getType() != piece->getType()) {
|
row--;
|
||||||
getPiece(row--, column)->isTaken();
|
}
|
||||||
piece->moveFwd();
|
else {
|
||||||
}
|
row++;
|
||||||
else {
|
}
|
||||||
cout << "Invalid move, there is a piece there.\n";
|
if(isPiece(row, column)) {
|
||||||
return;
|
cout << "Invalid move, there is a piece there.\n";
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
piece->moveFwd();
|
piece->moveFwd();
|
||||||
|
|
Reference in a new issue