Skip to content
Snippets Groups Projects
Commit cd7d49ad authored by MasterPyo's avatar MasterPyo
Browse files

enpassant resets only if we move something

parent d4727c23
No related merge requests found
......@@ -162,24 +162,24 @@ public class Main extends Application {
}
public void clickTile(TileView clickedTile) {
// --- Resets enPassant ---
for(int j = 1 ; j <= 8 ; j++) {
for(int i = 1 ; i <= 8 ; i++) {
Position p = new Position(i, j);
if (board.isPawn(p)) {
((Pawn) board.getPiece(p)).setEnPassant(false);
}
if (board.isNwap(p)) {
((Nwap) board.getPiece(p)).setEnPassant(false);
}
}
}
// --- Analyses the clicked tile type, and executes related actions ---
int state = clickedTile.getState();
Position selected = board.getSelected();
Position arrival = clickedTile.getPosition();
if(state != TileView.NORMAL && state != TileView.SELECTED) {
// --- Resets enPassant ---
for(int j = 1 ; j <= 8 ; j++) {
for(int i = 1 ; i <= 8 ; i++) {
Position p = new Position(i, j);
if (board.isPawn(p)) {
((Pawn) board.getPiece(p)).setEnPassant(false);
}
if (board.isNwap(p)) {
((Nwap) board.getPiece(p)).setEnPassant(false);
}
}
}
// --- ALL SPECIAL MOVES ---
if(state == TileView.SPECIAL) {
if(board.isPawn(selected) || board.isNwap(selected)) {
......
No preview for this file type
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment