New move method in ChessEngine

ChessEngine
Justin 2025-06-18 18:29:02 +02:00
parent c2e98386a8
commit cf0a8173b4
1 changed files with 14 additions and 0 deletions

View File

@ -1,6 +1,8 @@
package de.hs_mannheim.informatik.chess.model;
import com.github.bhlangonijr.chesslib.Board;
import com.github.bhlangonijr.chesslib.Square;
import com.github.bhlangonijr.chesslib.move.Move;
public class ChessEngine {
private Board board;
@ -8,4 +10,16 @@ public class ChessEngine {
public ChessEngine() {
board = new Board();
}
public boolean move(String from, String to) {
Move move = new Move(Square.valueOf(from.toUpperCase()), Square.valueOf(to.toUpperCase()));
if (board.legalMoves().contains(move)) {
board.doMove(move);
return true;
} else {
return false;
}
}
}