Skip to content

Commit 9aa572b

Browse files
committed
Small usability improvements.
Only start the move selection if the click is on a piece from the side to move (avoid some unnecessary "wrong move" messages) Tell again which side is to move in the wrong move message.
1 parent 7916567 commit 9aa572b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,9 @@ impl Sandbox for OfflinePuzzles {
525525
fn update(&mut self, message: Message) {
526526
match (self.from_square, message) {
527527
(None, Message::SelectSquare(pos)) => {
528-
self.from_square = Some(pos);
528+
if self.is_playing && self.board.color_on(pos.posgui_to_square()) == Some(self.board.side_to_move()) {
529+
self.from_square = Some(pos);
530+
}
529531
} (Some(from), Message::SelectSquare(to)) if from != to => {
530532
self.from_square = None;
531533

@@ -611,7 +613,11 @@ impl Sandbox for OfflinePuzzles {
611613
self.puzzle_status = String::from("Correct! What now?");
612614
}
613615
} else {
614-
self.puzzle_status = String::from("Ops! Wrong move...");
616+
if self.board.side_to_move() == Color::White {
617+
self.puzzle_status = String::from("Ops! Wrong move... White to play.");
618+
} else {
619+
self.puzzle_status = String::from("Ops! Wrong move... Black to play.");
620+
}
615621
}
616622
}
617623
} (Some(_), Message::SelectSquare(to)) => {

0 commit comments

Comments
 (0)