Skip to content

Commit

Permalink
Update LiseChessEngine.java
Browse files Browse the repository at this point in the history
  • Loading branch information
jalpp authored Feb 12, 2024
1 parent 4731549 commit 5322bd7
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/main/java/engine/LiseChessEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,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){
ChessUtil chessUtil = new ChessUtil();
return chessUtil.getImageFromFEN(this.board.getFen(), isBlack, "brown", "kosal");
return this.getImageFromFEN(this.board.getFen(), isBlack, "brown", "kosal");
}


Expand Down

0 comments on commit 5322bd7

Please sign in to comment.