Skip to content

Commit abea782

Browse files
committed
Piece does not have to be unselected anymore
1 parent 04920f5 commit abea782

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/java/pl/nogacz/chess/board/Board.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ public void readMouseEvent(MouseEvent event) {
125125
endGame("You loss. Maybe you try again?");
126126
}
127127
} else if(eventCoordinates.isValid()) {
128-
129128
if(isSelected) {
130129
if(eventCoordinates.equals(selectedCoordinates)) {
131130
selectedCoordinates = null;
@@ -149,6 +148,15 @@ public void readMouseEvent(MouseEvent event) {
149148
checkPromote(eventCoordinates, 0);
150149

151150
computerMove();
151+
} else if(isFieldNotNull(eventCoordinates) && Board.getPawn(eventCoordinates).getColor().isWhite() && isPossibleSelect(eventCoordinates, PawnColor.WHITE)) {
152+
possibleMovePromote.clear();
153+
possibleKickPromote.clear();
154+
155+
unLightSelect(selectedCoordinates);
156+
157+
selectedCoordinates = eventCoordinates;
158+
isSelected = true;
159+
lightSelect(eventCoordinates);
152160
}
153161
} else {
154162
if(isFieldNotNull(eventCoordinates)) {

0 commit comments

Comments
 (0)