summaryrefslogtreecommitdiff
path: root/src/Board.hpp
blob: a3981bc90fb4971c0663c734e7725914f4081419 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "Piece.hpp"
#include <algorithm>
#include <exception>
#include <iostream>
#include <string>

namespace chessarbiter {

class Board {
  std::vector<Piece> pieces;

public:
  /// @brief Check if a square is empty
  bool IsEmpty(std::string);
  /// @brief Add a piece (no checks are performed on coord)
  bool AddPiece(char p, std::string);
  /// @brief Remove a piece from a square
  bool RemovePiece(std::string);
  /// @brief Get piece at a specific coordinate
  Piece GetPieceAt(std::string);
  /// @brief Get the pieces of a player
  std::vector<Piece> GetPlayerPieces(bool);
  /// @brief Count the number of a specific piece on the board
  short CountPiece(char);
  /// @brief Return true if at most 1 similar piece can go to move_dst
  bool IsPieceMoveUnique(char piece, std::string move_dst);
  /// @brief Get the location of the first king found on the board
  std::string GetKingLocation(bool);
  /// @brief Check if a move is technically possible (does not means it is
  /// legal)
  bool IsMovePossible(std::string);
  /// @brief Clear the board
  void Clear();
  /// @brief Move a piece somewhere no matter what
  void Move(std::string);
  /// @brief Get a serialize version of the board
  std::string Serialize();
  /// @brief List all the technically possible moves of a player
  std::vector<std::string> ListPossibleMoves(bool);
};

struct NoPieceFound : public std::exception {
  const char *what() const throw() { return "No piece found"; }
};

} // namespace chessarbiter