chess-move-interface/src/HalfMove.hpp

54 lines
1.3 KiB
C++
Raw Normal View History

2022-01-26 20:50:24 +01:00
#pragma once
#include "Types.hpp"
2022-01-25 10:53:10 +01:00
#include <sstream>
#include <string>
#include <vector>
2023-01-19 15:51:12 +01:00
#include "CMI.hpp"
2022-01-25 10:53:10 +01:00
namespace pgnp {
/**
* Most members are public for conveniance sake
*/
class HalfMove {
private:
/// @brief Recursive dump
2023-01-15 14:23:54 +01:00
std::string NestedDump(const HalfMove *, int) const;
2022-01-25 10:53:10 +01:00
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;
2023-01-18 18:42:13 +01:00
std::uint8_t NAG;
2022-01-25 10:53:10 +01:00
/// @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
2023-01-15 14:23:54 +01:00
int GetLength() const;
2022-01-25 10:53:10 +01:00
/// @brief Dump move and all its variations
2023-01-15 14:23:54 +01:00
std::string Dump() const;
2022-01-25 10:53:10 +01:00
/// @brief Perform a deep copy of a HalfMove
void Copy(HalfMove *copy);
2022-01-26 20:50:24 +01:00
/// @brief Get HalfMove located x down the MainLine
HalfMove *GetHalfMoveAt(int);
2023-01-19 15:51:12 +01:00
/// @brief Get CMI version of HalfMove
CMI::HalfMove *GetAsCMI();
2022-01-25 14:53:34 +01:00
};
struct HalfMoveOutOfRange : public std::exception {
2022-01-26 20:50:24 +01:00
const char *what() const throw() {
return "HalfMove distance is out of range";
}
2022-01-25 10:53:10 +01:00
};
} // namespace pgnp