ochess/src/game_tab/HalfMove.hpp

56 lines
1.9 KiB
C++
Raw Normal View History

2022-02-23 18:11:55 +01:00
#pragma once
2023-01-19 16:33:44 +01:00
#include "CMI.hpp"
2022-02-23 18:11:55 +01:00
#include "ChessArbiter.hpp"
#include "ochess.hpp"
#include "pgnp.hpp"
#include <map>
#include <vector>
/**
2023-01-13 10:42:57 +01:00
* @brief This class extends CGEHalfMove (to be displayed in the game editor)
2022-02-23 18:11:55 +01:00
*/
2023-01-19 16:33:44 +01:00
class HalfMove : public CMI::HalfMove {
2022-02-23 18:11:55 +01:00
std::string fen;
2023-01-13 10:42:57 +01:00
/// @brief Used in to retrieve captured pieces (see GetLineCaptures())
2022-02-23 18:11:55 +01:00
char capture;
2022-02-25 11:42:46 +01:00
void BuildAndVerify(HalfMove *m, std::string fen);
2023-01-13 10:42:57 +01:00
/// @brief Store the source and destination square of the current move (mainly used for pieces animation)
2023-01-02 10:12:20 +01:00
std::string src,dst;
2023-01-16 14:55:48 +01:00
/// @brief Opening reach by that move while taking into account all the parents
std::string opening, eco;
2023-01-19 16:33:44 +01:00
chessarbiter::ChessArbiter arbiter;
2022-02-23 18:11:55 +01:00
public:
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);
2023-01-19 16:33:44 +01:00
HalfMove(CMI::HalfMove *m);
2022-02-23 18:11:55 +01:00
void AddMove(HalfMove *m);
/// @brief Check if current half move is within a variation
bool IsVariation();
/// @brief Get the root of a variation
2023-01-01 19:13:34 +01:00
bool HasParent(HalfMove*m);
bool HasChild(HalfMove*m);
2023-01-16 14:55:48 +01:00
/// @brief Retrieve the list of moves from the current one to the first one
std::vector<HalfMove *> GetLine();
std::string GetLineAsSAN();
2022-02-23 18:11:55 +01:00
std::map<char, std::uint8_t> GetLineCaptures();
2023-01-16 14:55:48 +01:00
/// @brief The opening name of current line
void SetOpening(const std::string &name, const std::string &eco);
/// @brief Getters for name and eco
void GetOpening(std::string &name, std::string &eco);
2022-02-23 18:11:55 +01:00
std::string GetFen();
void SetFen(std::string fen);
void SetCapture(char c);
2023-01-02 10:12:20 +01:00
void GetAbsoluteMove(std::string &src,std::string &dst);
void SetAbsoluteMove(const std::string &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
};