Integrate Chess Move Interface

This commit is contained in:
Loic Guegan 2023-01-19 15:51:12 +01:00
parent da88575493
commit 81f06cb209
7 changed files with 39 additions and 8 deletions

View file

@ -78,4 +78,20 @@ HalfMove *HalfMove::GetHalfMoveAt(int distance) {
return (tmp);
}
CMI::HalfMove *HalfMove::GetAsCMI(){
CMI::HalfMove *m=new CMI::HalfMove();
m->SetSAN(move);
m->SetNumber(count);
m->SetIsBlack(isBlack);
m->SetComment(comment);
m->SetNAG(NAG);
if(MainLine!=NULL){
m->SetMainline(MainLine->GetAsCMI());
}
for (HalfMove *var : variations) {
m->AddVariation(var->GetAsCMI());
}
return m;
}
} // namespace pgnp

View file

@ -5,6 +5,8 @@
#include <string>
#include <vector>
#include "CMI.hpp"
namespace pgnp {
/**
@ -40,6 +42,8 @@ public:
void Copy(HalfMove *copy);
/// @brief Get HalfMove located x down the MainLine
HalfMove *GetHalfMoveAt(int);
/// @brief Get CMI version of HalfMove
CMI::HalfMove *GetAsCMI();
};
struct HalfMoveOutOfRange : public std::exception {