dev: formatting fixes, additional Piece logic and properties, etc
This commit is contained in:
parent
cc37d834fe
commit
b0afa6cd78
7 changed files with 295 additions and 21 deletions
10
Piece.cpp
10
Piece.cpp
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue