dev: formatting fixes, additional Piece logic and properties, etc

This commit is contained in:
A.M. Rowsell 2025-08-09 07:06:24 -04:00
commit b0afa6cd78
Signed by untrusted user who does not match committer: amr
GPG key ID: E0879EDBDB0CA7B1
7 changed files with 295 additions and 21 deletions

View file

@ -125,13 +125,13 @@ std::vector<Move> Pawn::getLegalMoves(const Square &from, const Board &board) co
if (!target && !(board.boardGrid[r + 1][f])) // check both squares for pieces of any colour
moveList.push_back({from, targetSquare});
else
break;
continue;
} else if (abs(dir[1]) == 1) { // attempted capture (diagonal)
if (target && target->getColour() != this->getColour()) {
// legal capture
moveList.push_back({from, targetSquare});
} else {
break;
continue;
}
} else { // normal one square forward
if (!target)
@ -153,16 +153,16 @@ std::vector<Move> Pawn::getLegalMoves(const Square &from, const Board &board) co
if (dir[0] == 2 && !this->checkIfMoved()) {
// then 2 is potentially legal
if (!target && !(boardGrid[r - 1][f]))
if (!target && !(board.boardGrid[r - 1][f]))
moveList.push_back({from, targetSquare});
else
break;
continue;
} else if (abs(dir[1]) == 1) { // attempted capture (diagonal)
if (target && target->getColour() != this->getColour()) { // can only move there if it's a capture
// legal capture
moveList.push_back({from, targetSquare});
} else {
break;
continue;
}
} else { // normal one square forward
if (!target)