nicolaswinkler 7 lat temu
rodzic
commit
9b6b8927dc
3 zmienionych plików z 15 dodań i 3 usunięć
  1. 12 0
      src/ChessGame.cpp
  2. 2 2
      src/ChessGame.h
  3. 1 1
      src/main.cpp

+ 12 - 0
src/ChessGame.cpp

@@ -148,3 +148,15 @@ std::string ChessGame::generateFen(void) const
 }
 
 
+UndoInfo ChessGame::doMove(const MoveInfo& mi)
+{
+    UndoInfo ui;
+    ui.before = board;
+    return ui;
+}
+
+
+void ChessGame::undoMove(const UndoInfo& ui)
+{
+    board = ui.before;
+}

+ 2 - 2
src/ChessGame.h

@@ -37,6 +37,7 @@ struct chessy::MoveInfo
 
 struct chessy::UndoInfo
 {
+    Board before;
 };
 
 
@@ -88,8 +89,7 @@ public:
     inline Index getEnPassantIndex(void) const  { return enPassant; }
 
     UndoInfo doMove(const MoveInfo& mi);
-    void undoMove(const UndoInfo ui);
+    void undoMove(const UndoInfo& ui);
 };
 
 #endif // CHESSY_CHESSGAME_H
-

+ 1 - 1
src/main.cpp

@@ -103,4 +103,4 @@ auto main(int argc, char** argv) -> int
     }
     return 0;
 }
-*/
+*/