ochess/src/game_tab/HalfMove.hpp

72 lines
2 KiB
C++
Raw Normal View History

2022-02-23 18:11:55 +01:00
#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 {
2022-12-31 20:45:03 +01:00
HalfMove *parent = nullptr;
HalfMove *mainline = nullptr;
2022-02-25 11:42:46 +01:00
chessarbiter::ChessArbiter arbiter;
2022-02-23 18:11:55 +01:00
std::vector<HalfMove *> variations;
std::string fen;
char capture;
2022-02-25 11:42:46 +01:00
void BuildAndVerify(HalfMove *m, std::string fen);
2022-12-29 10:08:22 +01:00
std::string move_absolute;
2022-02-23 18:11:55 +01:00
public:
2022-12-29 10:08:22 +01:00
2022-12-30 18:43:21 +01:00
HalfMove(HalfMove *m);
2022-12-29 10:08:22 +01:00
HalfMove(std::string move_absolute,std::string move_san);
HalfMove(std::string move_absolute,std::string move_san, std::string fen);
2022-02-25 11:42:46 +01:00
HalfMove(pgnp::HalfMove *m);
2022-02-23 18:11:55 +01:00
~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();
2022-03-01 15:58:02 +01:00
std::vector<HalfMove *> GetVariations();
2022-02-23 18:11:55 +01:00
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);
2022-03-01 15:58:02 +01:00
bool IsABlackMove();
2022-12-29 10:08:22 +01:00
std::string GetAbsoluteMove(){return move_absolute;};
2022-02-25 13:38:49 +01:00
/**
* @brief Build current move
* Verify and play all the moves in the game
* while building the fen for each move
*/
2022-02-25 11:42:46 +01:00
void BuildAndVerify(std::string initial_fen);
2022-02-23 18:11:55 +01:00
};