Browse Source

TEMP commit for later pull and deletion

Nick Stolbov 3 years ago
parent
commit
a05e4b23a7
  1. 26
      src/main/java/Game/ChessObj/ChessBoard.java

26
src/main/java/Game/ChessObj/ChessBoard.java

@ -82,6 +82,32 @@ public class ChessBoard {
return false; return false;
} }
public boolean validateMove(int sourceX, int sourceY, int destX, int destY) {
if (!isCellInBoard(sourceX, sourceY) || !isCellInBoard(destX, destY))
return false;
ChessFigure figure = board[sourceY][sourceX];
if(board[destY][destX] == null || (board[destY][destX].getTeam() != figure.getTeam()))
return false;
int deltaX = destX - sourceX;
int deltaY = sourceY - destY;
//Pawn special case
if(figure.getType() == ChessFigure.Type.PAWN){
//FUCKED Pawn can destroy Enemy backwards
if((deltaX == -1 || deltaX == 1) && (deltaY == 1 || deltaY == -1) && (board[destY][destX] != null && board[destY][destX].getTeam() != figure.getTeam()))
return true;
if(figure.isRelativeMoveValid(deltaX, deltaY))
return true;
}
if(figure.isRelativeMoveValid(deltaX, deltaY)){
if(figure.getType() == ChessFigure.Type.KNIGHT)
return true;
if(validateCleanPath(sourceX, sourceY, destX, destY))
return true;
}
return false;
}
protected boolean validateCleanPath(int sourceX, int sourceY, final int destX, final int destY) { protected boolean validateCleanPath(int sourceX, int sourceY, final int destX, final int destY) {
int deltaX = destX - sourceX; int deltaX = destX - sourceX;
int deltaY = destY - sourceY; int deltaY = destY - sourceY;

Loading…
Cancel
Save