aboutsummaryrefslogtreecommitdiff
path: root/src/base_tab
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2023-01-19 16:33:44 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2023-01-19 16:33:44 +0100
commita1289dec3dcec278f9cf6d18a001b3146b11b7b2 (patch)
tree99fcdcba7f08f57994ec11c4c68c87339dff8ef3 /src/base_tab
parentaa6ec0ea601ac2a0b11752d210ce67fdb85ee60f (diff)
Integrate CMI
Diffstat (limited to 'src/base_tab')
-rw-r--r--src/base_tab/gamebase/PGNGameBase.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/base_tab/gamebase/PGNGameBase.cpp b/src/base_tab/gamebase/PGNGameBase.cpp
index 5d0bf57..a969451 100644
--- a/src/base_tab/gamebase/PGNGameBase.cpp
+++ b/src/base_tab/gamebase/PGNGameBase.cpp
@@ -47,7 +47,7 @@ std::shared_ptr<Game> PGNGameBase::GetCurrentGame() {
g=new Game(fen);
}
else {
- HalfMove *m = new HalfMove(pgnp_moves);
+ HalfMove *m = new HalfMove(pgnp_moves->GetAsCMI());
m->SetFen(fen);
g=new Game(m, fen);
}
@@ -156,7 +156,7 @@ std::string PGNGameBase::GetPGN(std::shared_ptr<Game> g) {
}
if(m !=nullptr){
- pgn += GetMovesPGN(m,m->IsABlackMove());
+ pgn += GetMovesPGN(m,m->IsBlack());
pgn += " ";
}
@@ -168,32 +168,35 @@ std::string PGNGameBase::GetMovesPGN(HalfMove *m, bool needDots) {
std::string part;
bool newNeedDots = false;
- if (!m->IsABlackMove() || needDots) {
- part += std::to_string(m->Number) + ".";
+ if (!m->IsBlack() || needDots) {
+ part += std::to_string(m->GetNumber()) + ".";
if (needDots) {
part += "..";
}
}
- part += m->move;
+ part += m->GetSAN();
- if (m->comment.size() > 0) {
+ if(m->GetNAG()>0)
+ part += " $" + std::to_string(m->GetNAG());
+
+ if (m->GetComment().size() > 0) {
part += " {";
- part += m->comment;
+ part += m->GetComment();
part += "}";
newNeedDots = true;
}
if (m->GetVariations().size() > 0) {
newNeedDots = true;
- for (HalfMove *v : m->GetVariations()) {
+ for (CMI::HalfMove *v : m->GetVariations()) {
part += " (";
- part += GetMovesPGN(v, m->IsABlackMove());
+ part += GetMovesPGN(static_cast<HalfMove*>(v), m->IsBlack());
part += ")";
}
}
if (m->GetMainline() != nullptr) {
- part += " " + GetMovesPGN(m->GetMainline(), !m->IsABlackMove() && newNeedDots);
+ part += " " + GetMovesPGN(static_cast<HalfMove*>(m->GetMainline()), !m->IsBlack() && newNeedDots);
}
return (part);