diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2023-01-10 16:18:23 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2023-01-10 16:18:23 +0100 |
| commit | 6f48becb9186a399e3a4dddb778570e7057752c7 (patch) | |
| tree | 64d8e53f3c1823ab496de1cfe532429a50842216 /src/ChessArbiter.cpp | |
| parent | 9e8b8d630cdf7dfafdd0a37bb095b4e4afe10478 (diff) | |
Improve pawn promotion API
Diffstat (limited to 'src/ChessArbiter.cpp')
| -rw-r--r-- | src/ChessArbiter.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/ChessArbiter.cpp b/src/ChessArbiter.cpp index dece4b9..2830bc1 100644 --- a/src/ChessArbiter.cpp +++ b/src/ChessArbiter.cpp @@ -3,7 +3,7 @@ namespace chessarbiter { ChessArbiter::ChessArbiter() : wPawn(1), wRook(5), wKnight(3), wBishop(3), wQueen(9), wKing(0), SAN(""), - capture(' '), was_enpassant(false) { + capture(' '), was_enpassant(false), was_pawn_promotion(false) { Setup("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"); } @@ -51,6 +51,7 @@ bool ChessArbiter::Play(const std::string &move, char promote) { SAN = ""; capture = ' '; was_enpassant=false; + was_pawn_promotion=false; if (IsCapture) { capture = board.GetPieceAt(dst).piece; @@ -131,10 +132,12 @@ bool ChessArbiter::Play(const std::string &move, char promote) { board.RemovePiece(dst); board.AddPiece(tolower(promote),dst); SAN+="="+toupper(promote); + was_pawn_promotion=true; } else if(dst[1]=='8'){ board.RemovePiece(dst); board.AddPiece(toupper(promote),dst); SAN+="="+toupper(promote); + was_pawn_promotion=true; } } // Captures reset half moves @@ -189,6 +192,8 @@ bool ChessArbiter::Play(const std::string &move, char promote) { bool ChessArbiter::WasEnPassant() { return (was_enpassant); } +bool ChessArbiter::WasPawnPromotion() { return (was_pawn_promotion); }; + bool ChessArbiter::IsAttacked(const std::string &square, bool by) { std::vector<std::string> moves = board.ListPossibleMoves(by); for (std::string &m : moves) { |
