Closed Starlight-30036225 closed 7 months ago
public boolean move(Piece[][] board,String NewLocation) { if (GetPossibleMoves(board).contains(NewLocation)){ int oldx = x; int oldy = y; x = Character.getNumericValue(NewLocation.charAt(0)); y = Character.getNumericValue(NewLocation.charAt(1)); board[x][y] = this; board[oldx][oldy] = null; return true; } return false; }
This is a function inside the base piece class, it checks if a move is valid, then if it is executes it. Updating both its internal location value and its position on the board. Making its previous location null.
This function will need to be overriden by pawns and kings for their special rules (En-passant and castling respectively).
But first lets see if this works.
Works as expected
Now that the client can request for pieces to be moved, I need to allow them to actually be moved. This should be very simple but lets see.