This commit is contained in:
CT
2026-05-08 13:53:54 -05:00
parent 7a1844c06a
commit a0f424fada
7 changed files with 58 additions and 20 deletions

View File

@@ -103,8 +103,11 @@ public class Chess extends JPanel implements ActionListener, MouseListener {
}
// if selecting a blank square -- must have one of ours selected
else if (selected != null && selected.color.equals(turnColor) && legalMoves.contains(pos)) {
board.move(selected, pos);
if (selected instanceof King && Math.abs(pos.x - selected.pos.x) == 2) {
board.castle((King) selected, pos.x > selected.pos.x);
} else {
board.move(selected, pos);
}
selected = null;
legalMoves = null;
turnColor = turnColor.equals("White") ? "Black" : "White";