aboutsummaryrefslogtreecommitdiff
path: root/src/HalfMove.hpp
blob: e04957105461cd46f19bd14ae18dcc682766fbc2 (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
#include <sstream>
#include <string>
#include <vector>

namespace pgnp {

/**
 * Most members are public for conveniance sake
 */
class HalfMove {
private:
  /// @brief Recursive dump
  std::string NestedDump(HalfMove *, int);

public:
  /// @brief Contains current move count
  int count;
  /// @brief Is this move for black
  bool isBlack;
  /// @brief The SAN move
  std::string move;
  /// @brief Comment associated to the move
  std::string comment;
  /// @brief Next HalfMove link to this line
  HalfMove *MainLine;
  /// @brief Next HalfMove links to variation of this line
  std::vector<HalfMove *> variations;

  HalfMove();
  ~HalfMove();
  /// @brief Get number of HalfMove in the MailLine
  int GetLength();
  /// @brief Dump move and all its variations
  std::string Dump();
  /// @brief Perform a deep copy of a HalfMove
  void Copy(HalfMove *copy);
  /// @brief Get HalfMove located x down the MainLine 
  HalfMove* GetHalfMoveAt(int);
};

struct HalfMoveOutOfRange : public std::exception {
  const char *what() const throw() { return "HalfMove distance is out of range"; }
};
} // namespace pgnp