From a1289dec3dcec278f9cf6d18a001b3146b11b7b2 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Thu, 19 Jan 2023 16:33:44 +0100 Subject: Integrate CMI --- src/base_tab/gamebase/PGNGameBase.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/base_tab/gamebase/PGNGameBase.cpp') 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 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 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(v), m->IsBlack()); part += ")"; } } if (m->GetMainline() != nullptr) { - part += " " + GetMovesPGN(m->GetMainline(), !m->IsABlackMove() && newNeedDots); + part += " " + GetMovesPGN(static_cast(m->GetMainline()), !m->IsBlack() && newNeedDots); } return (part); -- cgit v1.2.3