New move method in ChessEngine
parent
c2e98386a8
commit
cf0a8173b4
|
|
@ -1,6 +1,8 @@
|
||||||
package de.hs_mannheim.informatik.chess.model;
|
package de.hs_mannheim.informatik.chess.model;
|
||||||
|
|
||||||
import com.github.bhlangonijr.chesslib.Board;
|
import com.github.bhlangonijr.chesslib.Board;
|
||||||
|
import com.github.bhlangonijr.chesslib.Square;
|
||||||
|
import com.github.bhlangonijr.chesslib.move.Move;
|
||||||
|
|
||||||
public class ChessEngine {
|
public class ChessEngine {
|
||||||
private Board board;
|
private Board board;
|
||||||
|
|
@ -8,4 +10,16 @@ public class ChessEngine {
|
||||||
public ChessEngine() {
|
public ChessEngine() {
|
||||||
board = new Board();
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue