diff options
Diffstat (limited to 'src/CGEHalfMove.cpp')
| -rw-r--r-- | src/CGEHalfMove.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/CGEHalfMove.cpp b/src/CGEHalfMove.cpp new file mode 100644 index 0000000..7a5d095 --- /dev/null +++ b/src/CGEHalfMove.cpp @@ -0,0 +1,59 @@ +#include "CGEHalfMove.hpp" + +namespace cgeditor { + +CGEHalfMove::CGEHalfMove() + : MainLine(NULL), IsBlack(false), Number(1), Parent(NULL) {} + +CGEHalfMove::CGEHalfMove(CGEHalfMove *parent) { + CGEHalfMove(); + Parent = parent; + Parent->MainLine = this; + if (parent->IsBlack) { + Number = parent->Number + 1; + IsBlack = false; + } else { + Number = parent->Number; + IsBlack = true; + } +} + +CGEHalfMove::CGEHalfMove(std::string move) + : MainLine(NULL), IsBlack(false), Number(0), Parent(NULL) { + this->move = move; +} + +void CGEHalfMove::SetComment(const std::string &c) { + if (c.size() > 0) { + NbLineComment = 1; + for (const char &c : c) { + if (c == '\n') { + NbLineComment++; + } + } + this->comment = c; + } +} + +std::string CGEHalfMove::GetComment() { return (comment); } + +std::uint16_t CGEHalfMove::GetNbLineComment() { return (this->NbLineComment); } + +void CGEHalfMove::RemoveChild(CGEHalfMove *m) { + std::uint32_t i = 0; + bool found = false; + for (i; i < variations.size(); i++) { + if (variations[i] == m) { + found = true; + break; + } + } + if (found) { + variations.erase(variations.begin() + i); + } + if (MainLine == m) { + MainLine = NULL; + } +} + +} // namespace cgeditor
\ No newline at end of file |
