ChessGame.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef CHESSY_CHESSGAME_H
  2. #define CHESSY_CHESSGAME_H
  3. #include <vector>
  4. #include <string>
  5. #include "Board.h"
  6. namespace chessy
  7. {
  8. class ChessGame;
  9. }
  10. class chessy::ChessGame
  11. {
  12. Board board;
  13. bool canCastleQueenSide[2] = { true, true };
  14. bool canCastleKingSide [2] = { true, true };
  15. short reversibleHalfMoves = 0;
  16. //! -1 for no en passant possible
  17. Index enPassant = -1;
  18. Side turn = WHITE_SIDE;
  19. int moveCount = 1;
  20. public:
  21. ChessGame(void);
  22. ChessGame(const std::string& fenString);
  23. ChessGame(const ChessGame&) = default;
  24. ~ChessGame(void) = default;
  25. bool isValidMove(const Move& move) const;
  26. std::vector<Move> getValidMoves(void) const;
  27. inline const Board& getBoard(void) const { return board; }
  28. inline Board& getBoard(void) { return board; }
  29. inline bool getCanCastleKingSide(Side side) const
  30. {
  31. return canCastleKingSide[side];
  32. }
  33. inline bool getCanCastleQueenSide(Side side) const
  34. {
  35. return canCastleQueenSide[side];
  36. }
  37. void move(Move move);
  38. inline Side getTurn(void) const { return turn; }
  39. void loadFromFen(const std::string& fenString);
  40. std::string generateFen(void) const;
  41. };
  42. #endif // CHESSY_CHESSGAME_H