small refactoring to get rid of compiler warning

This commit is contained in:
Karma Riuk 2025-02-06 16:18:13 +01:00
parent 72f3431418
commit 42484f4217

View File

@ -12,8 +12,7 @@ std::vector<Move> pawn_moves(const Board& b, const Coords xy) {
int dy = my_colour == Colour::White ? 1 : -1;
Coords left{xy.x - 1, xy.y + dy};
int8_t capturable_piece = b.squares[left.to_index()];
if (capturable_piece != 0) {
if (my_colour != b.colour_at(left))
if (capturable_piece != 0 && my_colour != b.colour_at(left)) {
if ((my_colour == White && left.y == 7)
|| (my_colour == Black && left.y == 0))
for (auto piece : {Rook, Knigt, Bishop, Queen})
@ -32,8 +31,7 @@ std::vector<Move> pawn_moves(const Board& b, const Coords xy) {
int dy = my_colour == Colour::White ? 1 : -1;
Coords right{xy.x + 1, xy.y + dy};
int8_t capturable_piece = b.squares[right.to_index()];
if (capturable_piece != 0) {
if (my_colour != b.colour_at(right))
if (capturable_piece != 0 && my_colour != b.colour_at(right)) {
if ((my_colour == White && right.y == 7)
|| (my_colour == Black && right.y == 0))