diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2023-01-02 10:12:20 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2023-01-02 10:12:20 +0100 |
| commit | 3e40032109886786e469796dced8523d60b90ee4 (patch) | |
| tree | ebc43bf9734b09a8e5887ca7877af9eac356cfd0 /src/game_tab/HalfMove.cpp | |
| parent | 98edb4253c0d131b855bee882530fa2b28906fc2 (diff) | |
Simplify absolute moves
Diffstat (limited to 'src/game_tab/HalfMove.cpp')
| -rw-r--r-- | src/game_tab/HalfMove.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/game_tab/HalfMove.cpp b/src/game_tab/HalfMove.cpp index 01621e2..ae63527 100644 --- a/src/game_tab/HalfMove.cpp +++ b/src/game_tab/HalfMove.cpp @@ -1,13 +1,13 @@ #include "HalfMove.hpp" HalfMove::HalfMove(std::string move_absolute,std::string move_san) : capture(' ') { - this->move_absolute=move_absolute; + SetAbsoluteMove(move_absolute); this->move = move_san; fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"; } HalfMove::HalfMove(std::string move_absolute, std::string move_san, std::string fen) : fen(fen), capture(' ') { - this->move_absolute=move_absolute; + SetAbsoluteMove(move_absolute); this->move = move_san; } @@ -21,7 +21,8 @@ HalfMove::~HalfMove() { } HalfMove::HalfMove(HalfMove *m){ - move_absolute=m->move_absolute; + src=m->src; + dst=m->dst; move=m->move; fen=m->fen; capture=m->capture; @@ -137,6 +138,11 @@ void HalfMove::SetAsMainline() { HalfMove *HalfMove::GetMainline() { return (mainline); } +void HalfMove::SetAbsoluteMove(const std::string &move_absolute){ + this->src=move_absolute.substr(0,2); + this->dst=move_absolute.substr(2,2); +} + HalfMove::HalfMove(pgnp::HalfMove *m) : capture(' ') { this->move = m->move; this->nag = m->NAG; @@ -151,6 +157,11 @@ HalfMove::HalfMove(pgnp::HalfMove *m) : capture(' ') { } } +void HalfMove::GetAbsoluteMove(std::string &src,std::string &dst){ + src=this->src; + dst=this->dst; +} + void HalfMove::SetFen(std::string fen) { this->fen = fen; } void HalfMove::Promote() { @@ -213,8 +224,9 @@ bool HalfMove::IsABlackMove() { return (IsBlack); } void HalfMove::BuildAndVerify(HalfMove *m, std::string fen) { arbiter.Setup(fen); - m->move_absolute=arbiter.ParseSAN(m->move); - bool work = arbiter.Play(m->move_absolute,arbiter.ParseSANPromotion(m->move)); + std::string move_absolute=arbiter.ParseSAN(m->move); + m->SetAbsoluteMove(move_absolute); + bool work = arbiter.Play(move_absolute,arbiter.ParseSANPromotion(m->move)); if (!work) { wxLogDebug("Bug! %s", m->move); } |
