diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-23 18:11:55 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-23 18:11:55 +0100 |
| commit | ce941c146aea7925bded6b9d2a0d0559d3156ad3 (patch) | |
| tree | 4c52e02600e3fd127bfb28b3e974d45541ec9e4e /src/game_tab/HalfMove.hpp | |
Create repository
Diffstat (limited to 'src/game_tab/HalfMove.hpp')
| -rw-r--r-- | src/game_tab/HalfMove.hpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/game_tab/HalfMove.hpp b/src/game_tab/HalfMove.hpp new file mode 100644 index 0000000..c8ef8c0 --- /dev/null +++ b/src/game_tab/HalfMove.hpp @@ -0,0 +1,57 @@ +#pragma once +#include "CGEditor.hpp" +#include "ChessArbiter.hpp" +#include "ochess.hpp" +#include "pgnp.hpp" +#include <map> +#include <vector> + +/** + * @brief Create your custom half move class + * + * The implementation of the class should give you + * an overview of how to keep your move sync with the one of CGEditor + * + */ +class HalfMove : public cgeditor::CGEHalfMove { + HalfMove *parent = NULL; + HalfMove *mainline = NULL; + std::vector<HalfMove *> variations; + std::string fen; + char capture; + std::string GetPGN(bool needDots); + +public: + HalfMove(std::string move); + HalfMove(std::string move, std::string fen); + HalfMove(pgnp::HalfMove *m, std::string initial_fen); + + ~HalfMove(); + /// @brief Add variation to current move + void AddVariation(HalfMove *m); + /// @brief Remove the specified child from mainline and/or variations + void RemoveChild(HalfMove *m); + void AddMove(HalfMove *m); + /// @brief Set value of the mailine + void SetMainline(HalfMove *m); + /// @brief Set this move as mainline + void SetAsMainline(); + /// @brief Promote the current move and submove + void Promote(); + /// @brief Check if current half move is within a variation + bool IsVariation(); + /// @brief Get the root of a variation + HalfMove *GetRoot(); + /// @brief Get parent of the current move + HalfMove *GetParent(); + HalfMove *GetMainline(); + std::map<char, std::uint8_t> GetLineCaptures(); + + /// @brief Set parent of the current move + void SetParent(HalfMove *m); + std::string GetFen(); + void SetFen(std::string fen); + void SetCapture(char c); + std::string GetPGN(); +}; + |
