aboutsummaryrefslogtreecommitdiff
path: root/src/game_tab
diff options
context:
space:
mode:
Diffstat (limited to 'src/game_tab')
-rw-r--r--src/game_tab/Game.hpp2
-rw-r--r--src/game_tab/HalfMove.cpp12
-rw-r--r--src/game_tab/HalfMove.hpp2
-rw-r--r--src/game_tab/left_panel/GameTabLeftPanel.cpp9
-rw-r--r--src/game_tab/left_panel/GameTabLeftPanel.hpp5
5 files changed, 8 insertions, 22 deletions
diff --git a/src/game_tab/Game.hpp b/src/game_tab/Game.hpp
index 25284ee..9398056 100644
--- a/src/game_tab/Game.hpp
+++ b/src/game_tab/Game.hpp
@@ -5,6 +5,8 @@
#include "ochess.hpp"
#include <unordered_map>
+#define UNPACK_ABSOLUTE_MOVE(MOVE,SRC,DST) {(SRC)=(MOVE).substr(0,2);(DST)=(MOVE).substr(2,2);}
+
class Game {
std::string board;
std::string initial_fen;
diff --git a/src/game_tab/HalfMove.cpp b/src/game_tab/HalfMove.cpp
index a78eb0d..7f19480 100644
--- a/src/game_tab/HalfMove.cpp
+++ b/src/game_tab/HalfMove.cpp
@@ -177,18 +177,6 @@ void HalfMove::Promote() {
}
}
-bool HalfMove::HasChild(HalfMove *m){
- if(m!=mainline){
- for(auto var: variations){
- if(m== var){
- return(true);
- }
- }
- return false;
- }
- return true;
-}
-
bool HalfMove::IsVariation() {
HalfMove *m = this;
HalfMove *p = HalfMove::parent;
diff --git a/src/game_tab/HalfMove.hpp b/src/game_tab/HalfMove.hpp
index 7bc8b22..3d5177e 100644
--- a/src/game_tab/HalfMove.hpp
+++ b/src/game_tab/HalfMove.hpp
@@ -45,8 +45,6 @@ public:
void Promote();
/// @brief Check if current half move is within a variation
bool IsVariation();
- /// @brief Return true if current moves has m as mainline or variation
- bool HasChild(HalfMove *m);
/// @brief Get the root of a variation
HalfMove *GetRoot();
/// @brief Get parent of the current move
diff --git a/src/game_tab/left_panel/GameTabLeftPanel.cpp b/src/game_tab/left_panel/GameTabLeftPanel.cpp
index e986653..1142e99 100644
--- a/src/game_tab/left_panel/GameTabLeftPanel.cpp
+++ b/src/game_tab/left_panel/GameTabLeftPanel.cpp
@@ -21,7 +21,6 @@ GameTabLeftPanel::GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game)
// Configure FEN field
fen_text_field->SetFont(wxFont(*wxNORMAL_FONT).Bold().Larger());
- last_move=game->GetCurrentMove();
// Bind events:
Bind(PLAY_MOVE_EVENT, &GameTabLeftPanel::OnPlay, this, wxID_ANY);
@@ -68,6 +67,7 @@ void GameTabLeftPanel::OnPlay(wxCommandEvent &event) {
event.SetEventObject(this);
ProcessEvent(event);
}
+ Notify(true);
}
void GameTabLeftPanel::Notify(bool skip_animation) {
@@ -78,12 +78,13 @@ void GameTabLeftPanel::Notify(bool skip_animation) {
bool animate=false;
HalfMove *m = game->GetCurrentMove();
std::string src,dst;
- if (m)
+ if (m){
captures = m->GetLineCaptures();
+ }
// Update board canvas:
- if(!skip_animation || animate){
+ if(skip_animation || !animate){
board_canvas->SetupBoard(chessarbiter::FENParser::Parse(fen).board,
game->IsBlackToPlay(), captures,
game->GetTag("White"),game->GetTag("Black"));
@@ -92,8 +93,6 @@ void GameTabLeftPanel::Notify(bool skip_animation) {
board_canvas->Animate(chessarbiter::FENParser::Parse(fen).board,
game->IsBlackToPlay(), captures,src,dst,repeat);
}
- // Update last move
- last_move=m;
// Update fen field:
fen_text_field->SetValue(game->GetFen());
}
diff --git a/src/game_tab/left_panel/GameTabLeftPanel.hpp b/src/game_tab/left_panel/GameTabLeftPanel.hpp
index 5073e9c..359b815 100644
--- a/src/game_tab/left_panel/GameTabLeftPanel.hpp
+++ b/src/game_tab/left_panel/GameTabLeftPanel.hpp
@@ -11,10 +11,9 @@ wxDECLARE_EVENT(GAME_CHANGE, wxCommandEvent);
class GameTabLeftPanel : public TabGameLeftPanel {
std::shared_ptr<Game> game;
BoardCanvas *board_canvas;
- std::string last_absolute_move;
bool repeat;
- HalfMove *last_move;
-
+ std::string last_absolute_move;
+
public:
GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game);
void Notify(bool skip_animation=false);