From fea3f6c98a343cc77e6be915bde55d53bfd36a5a Mon Sep 17 00:00:00 2001 From: Karma Riuk Date: Sun, 2 Feb 2025 18:24:23 +0100 Subject: [PATCH] fixed signature --- cpp/src/pieces/piece.cpp | 14 ++++++++++++-- cpp/src/pieces/piece.hpp | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cpp/src/pieces/piece.cpp b/cpp/src/pieces/piece.cpp index 533b641..9138015 100644 --- a/cpp/src/pieces/piece.cpp +++ b/cpp/src/pieces/piece.cpp @@ -2,14 +2,24 @@ #include "../board.hpp" -std::vector legal_moves(const Piece p, const Board& b, const Coords xy) { +std::vector legal_moves( + const Piece p, + const Board& b, + const Coords xy, + bool looking_for_check = false +) { + std::vector ret; switch (p) { case Piece::Pawn: - return pawn_moves(b, xy); + ret = pawn_moves(b, xy); case Piece::Bishop: break; default: break; } + + if (!looking_for_check) + return keep_only_blocking(ret, b); + return {}; } diff --git a/cpp/src/pieces/piece.hpp b/cpp/src/pieces/piece.hpp index 54eb7fd..121335d 100644 --- a/cpp/src/pieces/piece.hpp +++ b/cpp/src/pieces/piece.hpp @@ -23,7 +23,7 @@ enum Colour : int8_t { class Board; struct Coords; -std::vector legal_moves(const Piece, const Board&, const Coords); +std::vector legal_moves(const Piece, const Board&, const Coords, bool); std::vector pawn_moves(const Board&, const Coords); std::vector rook_moves(const Board&, const Coords);