astyle: reformatted all files

This commit is contained in:
A.M. Rowsell 2025-08-28 10:41:59 -04:00
commit 7722a84b2e
Signed by untrusted user who does not match committer: amr
GPG key ID: E0879EDBDB0CA7B1
5 changed files with 120 additions and 99 deletions

View file

@ -22,6 +22,28 @@ std::vector<Move> Piece::getLegalMoves(const Square &from, const Board &board) c
std::vector<Move> moveList;
return moveList;
}
bool King::checkForCheck() const {
std::vector<std::vector<int>> kingVulnerable = {
{-1, 0}, // Up
{-1, -1}, // up-left
{-1, 1}, // up-right
{1, 0}, // Down
{1, -1}, // down-left
{1, 1}, // down-right
{0, -1}, // Left
{0, 1}, // Right
{-1, -2}, // 1
{-1, 2}, // 2
{-2, -1}, // 3
{-2, 1}, // 4
{1, -2}, // 5
{1, 2}, // 6
{2, -1}, // 7
{2, 1} // 8
};
// locate our King
return inCheck;
}
std::vector<Move> King::getLegalMoves(const Square &from, const Board &board) const {
std::vector<Move> moveList;
@ -97,18 +119,20 @@ std::vector<Move> King::getLegalMoves(const Square &from, const Board &board) co
if(target && (target->getColour() != this->getColour())) { // is it occupied & an enemy?
if((target->getPieceType() == QUEEN || target->getPieceType() == BISHOP) && diagonal) {
// we are being attacked diagonally on this square, so remove it
moves.to.rank = INVALID_RANK; moves.to.file = INVALID_FILE;
}
else if(target->getPieceType() == KNIGHT && knight) {
moves.to.rank = INVALID_RANK;
moves.to.file = INVALID_FILE;
} else if(target->getPieceType() == KNIGHT && knight) {
// we are being attacked by a knight, so remove it
moves.to.rank = INVALID_RANK; moves.to.file = INVALID_FILE;
}
else if(target->getPieceType() == ROOK || target->getPieceType() == QUEEN && (!diagonal && !knight)) {
moves.to.rank = INVALID_RANK;
moves.to.file = INVALID_FILE;
} else if(target->getPieceType() == ROOK || target->getPieceType() == QUEEN && (!diagonal && !knight)) {
// again, being attacked, remove it
moves.to.rank = INVALID_RANK; moves.to.file = INVALID_FILE;
moves.to.rank = INVALID_RANK;
moves.to.file = INVALID_FILE;
}
if(target->getPieceType() == PAWN && (abs(r - startSquare.rank) == 1 && abs(f - startSquare.file) == 1)) {
moves.to.rank = INVALID_RANK; moves.to.file = INVALID_FILE;
moves.to.rank = INVALID_RANK;
moves.to.file = INVALID_FILE;
}
}
if(target && (target->getColour() == this->getColour())) {
@ -125,10 +149,10 @@ std::vector<Move> King::getLegalMoves(const Square &from, const Board &board) co
}
// will this actually work?
moveList.erase(
std::remove_if(moveList.begin(), moveList.end(),
[&](const auto &x) {
return !x.to.isValid();
}));
std::remove_if(moveList.begin(), moveList.end(),
[&](const auto & x) {
return !x.to.isValid();
}));
return moveList;
}