diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-16 20:22:42 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-16 20:23:08 +0100 |
| commit | 640d882099af0f7c13dc5e102943bb06c2df5400 (patch) | |
| tree | 5e65b3e0e3ad434ad130222c855d88e48fc44610 /src/ChessArbiter.hpp | |
| parent | 0584edb107467a294f17a50d063e667f22f4a47b (diff) | |
Cleaning arbiter:
- Add backup macros
- User can fetch last captured piece
Diffstat (limited to 'src/ChessArbiter.hpp')
| -rw-r--r-- | src/ChessArbiter.hpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/ChessArbiter.hpp b/src/ChessArbiter.hpp index e5cec69..541253c 100644 --- a/src/ChessArbiter.hpp +++ b/src/ChessArbiter.hpp @@ -4,18 +4,34 @@ #include <iostream> #include <unordered_map> +#define INIT_BACKUP() \ + FEN fen_backup = fen; \ + char positions_backup = 0; \ + if (positions.find(fen.board) != positions.end()) \ + positions_backup = positions[fen.board]; \ + std::string SAN_backup = SAN; \ + char capture_backup = capture; + +#define RESTORE_BACKUP() \ + SetFEN(fen_backup); \ + if (positions_backup != 0) \ + positions[fen.board] = positions_backup; \ + SAN = SAN_backup; \ + capture = capture_backup; + namespace chessarbiter { class ChessArbiter { Board board; FEN fen; - FEN fen_last; // To undo a move int wPawn, wRook, wKnight, wBishop, wQueen, wKing; /// @brief Use to compute occurences of positions std::unordered_map<std::string, char> positions; /// @brief FEN methods used internally void SetFEN(std::string); void SetFEN(FEN); - std::string SAN,SAN_last; + std::string SAN, SAN_last; + char capture, capture_last; + public: ChessArbiter(); void Setup(std::string); @@ -36,6 +52,7 @@ public: bool IsPlayable(); /// @brief Get pieces captures by a player std::string GetCaptures(bool); + char GetCapture(); /// @brief Get the english SAN format of the last move std::string GetSAN(); /// @brief List all the legal moves of a player |
