OChess v0.0.2
Programmer's Manual
HalfMove.hpp
1#pragma once
2#include "CMI.hpp"
3#include "ChessArbiter.hpp"
4#include "ochess.hpp"
5#include "pgnp.hpp"
6#include <map>
7#include <vector>
8
13class HalfMove : public CMI::HalfMove {
14 std::string fen;
16 char capture;
17 void BuildAndVerify(HalfMove *m, std::string fen);
19 std::string src,dst;
21 std::string opening, eco;
23 chessarbiter::ChessArbiter arbiter;
24
25public:
27 HalfMove(std::string move_absolute,std::string move_san);
28 HalfMove(std::string move_absolute,std::string move_san, std::string fen);
29 HalfMove(CMI::HalfMove *m);
30
37 void AddMove(HalfMove *m);
39 bool IsVariation();
47 bool HasParent(HalfMove*m);
55 bool HasChild(HalfMove*m);
57 std::vector<HalfMove *> GetLine();
58 std::string GetLineAsSAN();
59 std::map<char, std::uint8_t> GetLineCaptures();
61 void SetOpening(const std::string &name, const std::string &eco);
63 void GetOpening(std::string &name, std::string &eco);
64 std::string GetFen();
65 void SetFen(std::string fen);
66 void SetCapture(char c);
67 void GetAbsoluteMove(std::string &src,std::string &dst);
68 void SetAbsoluteMove(const std::string &move_absolute);
75 HalfMove* GetCurrentMoveWithFEN(const std::string fen);
81 void BuildAndVerify(std::string initial_fen);
82};
This class extends CGEHalfMove (to be displayed in the game editor)
Definition: HalfMove.hpp:13
std::string src
Store the source and destination square of the current move (mainly used for pieces animation)
Definition: HalfMove.hpp:19
void SetOpening(const std::string &name, const std::string &eco)
The opening name of current line.
Definition: HalfMove.cpp:14
chessarbiter::ChessArbiter arbiter
Arbiter used to ensure that chess rules are followed.
Definition: HalfMove.hpp:23
void GetOpening(std::string &name, std::string &eco)
Getters for name and eco.
Definition: HalfMove.cpp:26
bool HasParent(HalfMove *m)
Check if pointer m to a HalfMove is a parent of the current one.
Definition: HalfMove.cpp:134
bool HasChild(HalfMove *m)
Check if a given pointer m to a HalfMove is in mainline or variations of the current move.
Definition: HalfMove.cpp:138
char capture
Used in to retrieve captured pieces (see GetLineCaptures())
Definition: HalfMove.hpp:16
void AddMove(HalfMove *m)
Add mainline to the current move. If a mainline already exists, add to its variations.
Definition: HalfMove.cpp:98
std::vector< HalfMove * > GetLine()
Retrieve the list of moves from the current one to the first one.
Definition: HalfMove.cpp:31
bool IsVariation()
Check if current half move is within a variation.
Definition: HalfMove.cpp:151
std::string opening
Opening reach by that move while taking into account all the parents.
Definition: HalfMove.hpp:21
HalfMove * GetCurrentMoveWithFEN(const std::string fen)
Search if current move (move or its variations) contains a specific fen (usefull to not add moves tha...
Definition: HalfMove.cpp:166