diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-16 13:43:30 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-16 13:43:30 +0100 |
| commit | 94c2565647d84f31d5ccac0d88717aef29d4a9a1 (patch) | |
| tree | 4852e56188d1928b71424357f75e20a9cb5e8044 | |
| parent | 62d7a030d23f4c0704dbf731f4f42b4e9e08e8b7 (diff) | |
Debug piece capture
| -rw-r--r-- | src/Board.cpp | 2 | ||||
| -rw-r--r-- | tests/chessarbiter.cpp | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/Board.cpp b/src/Board.cpp index a107c02..6546354 100644 --- a/src/Board.cpp +++ b/src/Board.cpp @@ -74,9 +74,9 @@ std::string Board::GetKingLocation(bool isBlack) { void Board::Move(std::string move) { std::string src = move.substr(0, 2); std::string dst = move.substr(2, 2); + RemovePiece(dst); // Remove piece on dst if exists for (Piece &p : pieces) { if (p.coord == src) { - RemovePiece(dst); // Remove piece on dst if exists p.coord = dst; break; } diff --git a/tests/chessarbiter.cpp b/tests/chessarbiter.cpp index edee7f0..475816e 100644 --- a/tests/chessarbiter.cpp +++ b/tests/chessarbiter.cpp @@ -358,3 +358,13 @@ TEST_CASE("IsDrawByRepetitions", "[chessarbiter/IsDrawByRepetitions]") { a.Play("d6d7"); CHECK(a.IsDrawByRepetitions()); } + +TEST_CASE("SimpleCapture", "[SimplePieceCapture]") { + ChessArbiter a; + a.Setup("rnbqkbnr/ppp1pppp/8/3p4/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2"); + + // Ensure capture works + a.Play("e4d5"); + CHECK(a.GetFEN() == + "rnbqkbnr/ppp1pppp/8/3P4/8/8/PPPP1PPP/RNBQKBNR b KQkq - 0 2"); +} |
