From cb4f5ada5c91629e96f1daecaf85dc92bee5359d Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Tue, 1 Mar 2022 15:58:02 +0100 Subject: Move PGN export to the right place --- src/game_tab/Game.cpp | 13 +------------ src/game_tab/Game.hpp | 2 +- src/game_tab/HalfMove.cpp | 37 ++----------------------------------- src/game_tab/HalfMove.hpp | 5 +++-- 4 files changed, 7 insertions(+), 50 deletions(-) (limited to 'src/game_tab') diff --git a/src/game_tab/Game.cpp b/src/game_tab/Game.cpp index 8b52ca6..1bc1e4c 100644 --- a/src/game_tab/Game.cpp +++ b/src/game_tab/Game.cpp @@ -99,7 +99,6 @@ bool Game::Play(std::string move) { if (moves == NULL) { moves = m; } - wxLogDebug("%s", GetPGN()); return (true); } return (false); @@ -139,17 +138,7 @@ std::string Game::GetFen() { return (current->GetFen()); } -std::string Game::GetPGN() { - std::string pgn; - if (moves != NULL) { - for (auto const &element : tags) { - pgn += '[' + element.first + " \"" + element.second + "\"]\n"; - } - pgn += moves->GetPGN(); - } - pgn += " " + result; - return (pgn); -} +std::string Game::GetResult() { return (result); } void Game::SetResult(std::string result) { this->result = result; } diff --git a/src/game_tab/Game.hpp b/src/game_tab/Game.hpp index f0414c8..f70ebee 100644 --- a/src/game_tab/Game.hpp +++ b/src/game_tab/Game.hpp @@ -26,6 +26,7 @@ public: HalfMove *GetCurrentMove(); HalfMove *GetMoves(); std::string GetFen(); + std::string GetResult(); bool Play(std::string move); bool IsBlackToPlay(); void Previous(); @@ -35,7 +36,6 @@ public: void SetMoveAsMainline(HalfMove *m); void SetCurrent(HalfMove *m); std::vector ListTags(); - std::string GetPGN(); void SetResult(std::string result); /** * @brief Build current game diff --git a/src/game_tab/HalfMove.cpp b/src/game_tab/HalfMove.cpp index 0aa957e..0472b7c 100644 --- a/src/game_tab/HalfMove.cpp +++ b/src/game_tab/HalfMove.cpp @@ -172,42 +172,9 @@ bool HalfMove::IsVariation() { std::string HalfMove::GetFen() { return (fen); } -std::string HalfMove::GetPGN() { return (GetPGN(IsBlack)); } +std::vector HalfMove::GetVariations() { return (variations); } -std::string HalfMove::GetPGN(bool needDots) { - std::string part; - bool newNeedDots = false; - - if (!IsBlack || needDots) { - part += std::to_string(Number) + "."; - if (needDots) { - part += ".."; - } - } - part += move; - - if (GetNbLineComment() > 0) { - part += " {"; - part += GetComment(); - part += "}"; - newNeedDots = true; - } - - if (variations.size() > 0) { - newNeedDots = true; - for (HalfMove *v : variations) { - part += " ("; - part += v->GetPGN(IsBlack); - part += ")"; - } - } - - if (mainline != NULL) { - part += " " + mainline->GetPGN(!IsBlack && newNeedDots); - } - - return (part); -} +bool HalfMove::IsABlackMove() { return (IsBlack); } void HalfMove::BuildAndVerify(HalfMove *m, std::string fen) { arbiter.Setup(fen); diff --git a/src/game_tab/HalfMove.hpp b/src/game_tab/HalfMove.hpp index 51b38a0..6ea0c5a 100644 --- a/src/game_tab/HalfMove.hpp +++ b/src/game_tab/HalfMove.hpp @@ -20,7 +20,6 @@ class HalfMove : public cgeditor::CGEHalfMove { std::vector variations; std::string fen; char capture; - std::string GetPGN(bool needDots); void BuildAndVerify(HalfMove *m, std::string fen); public: @@ -47,6 +46,8 @@ public: /// @brief Get parent of the current move HalfMove *GetParent(); HalfMove *GetMainline(); + std::vector GetVariations(); + std::map GetLineCaptures(); /// @brief Set parent of the current move @@ -54,7 +55,7 @@ public: std::string GetFen(); void SetFen(std::string fen); void SetCapture(char c); - std::string GetPGN(); + bool IsABlackMove(); /** * @brief Build current move -- cgit v1.2.3