Skip to content

Commit

Permalink
add image gen method to replace chessutil old class
Browse files Browse the repository at this point in the history
  • Loading branch information
jalpp authored Apr 16, 2024
1 parent 7328ac5 commit 4ef836a
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/main/java/engine/LiseChessEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,30 @@ public void resetBoard() {
this.board = new Board();
}



public String getImageFromFEN(String fen, boolean isBlack, String boardColor, String pieceType) {
try {
String img;
this.board.loadFromFen(fen);
String[] getImgCord = this.board.getFen().split(" ");

if (fen.contains("w")) {
img = "https://lichess1.org/export/fen.gif?fen=" + getImgCord[0] + "&color=white&theme=" + boardColor + "&piece=" + pieceType;
} else {
img = "https://lichess1.org/export/fen.gif?fen=" + getImgCord[0] + "&color=black&theme=" + boardColor + "&piece=" + pieceType;
}

return img;

} catch (Exception e) {
return "Please provide a valid FEN!";
}
}


public String getImageOfCurrentBoard(boolean isBlack) {
return chessUtil.getImageFromFEN(this.board.getFen(), isBlack, "brown", "kosal");
return this.getImageFromFEN(this.board.getFen(), isBlack, "brown", "kosal");
}


Expand Down

0 comments on commit 4ef836a

Please sign in to comment.