mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:37:35 +00:00
Chess: Gracefully handle ChessEngine disconnections
The GUI now tracks when it becomes disconnected from ChessEngine. If not currently waiting for a move from ChessEngine, it will automatically reconnect on the next engine move. If a disconnection occurs while waiting for a move, the player is asked whether they want to try again or not.
This commit is contained in:
parent
55347ed6a5
commit
8b6c538f2a
4 changed files with 63 additions and 20 deletions
|
@ -473,12 +473,14 @@ void ChessWidget::input_engine_move()
|
|||
set_drag_enabled(false);
|
||||
|
||||
set_override_cursor(Gfx::StandardCursor::Wait);
|
||||
m_engine->get_best_move(board(), 4000, [this, drag_was_enabled](Chess::Move move) {
|
||||
m_engine->get_best_move(board(), 4000, [this, drag_was_enabled](ErrorOr<Chess::Move> move) {
|
||||
set_override_cursor(Gfx::StandardCursor::None);
|
||||
if (!want_engine_move())
|
||||
return;
|
||||
set_drag_enabled(drag_was_enabled);
|
||||
VERIFY(board().apply_move(move));
|
||||
if (!move.is_error())
|
||||
VERIFY(board().apply_move(move.release_value()));
|
||||
|
||||
m_playback_move_number = m_board.moves().size();
|
||||
m_playback = false;
|
||||
m_board_markings.clear();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue