Quicksave programmiert (muss nur noch mit Buttons verknüpft werden)
Variable: private MoveBackup quicksave = null; hinzugefügt Methoden: save() und load()Quicksave
parent
e6e1fa3187
commit
4b99d6e233
|
@ -3,6 +3,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import com.github.bhlangonijr.chesslib.Board;
|
||||
import com.github.bhlangonijr.chesslib.MoveBackup;
|
||||
import com.github.bhlangonijr.chesslib.Piece;
|
||||
import com.github.bhlangonijr.chesslib.Square;
|
||||
import com.github.bhlangonijr.chesslib.move.Move;
|
||||
|
@ -10,7 +11,9 @@ import com.github.bhlangonijr.chesslib.move.Move;
|
|||
public class ChessEngine {
|
||||
private Board board;
|
||||
private List<Move> moves = new ArrayList<>();
|
||||
private MoveBackup quicksave = null;
|
||||
|
||||
|
||||
public ChessEngine() {
|
||||
board = new Board();
|
||||
}
|
||||
|
@ -27,6 +30,25 @@ public class ChessEngine {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void save() {
|
||||
if (!moves.isEmpty()) {
|
||||
Move lastMove = moves.get(moves.size() - 1);
|
||||
quicksave = new MoveBackup(board, lastMove);
|
||||
System.out.println("Quicksave erstellt.");
|
||||
} else {
|
||||
System.out.println("Kein Zug vorhanden zum Speichern.");
|
||||
}
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (quicksave != null) {
|
||||
quicksave.restore(board);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<MoveDTO> getLegalDestinations(String from) {
|
||||
List<MoveDTO> destinations = new ArrayList<>();
|
||||
Square fromSq = Square.valueOf(from.toUpperCase());
|
||||
|
|
Loading…
Reference in New Issue