summaryrefslogtreecommitdiff
path: root/Games/Chess/main.cpp
diff options
context:
space:
mode:
authorBrendan Coles <bcoles@gmail.com>2020-12-17 03:01:58 +0000
committerAndreas Kling <kling@serenityos.org>2020-12-17 19:45:05 +0100
commit172707a94585b739cfeef4aefdddb475ed2ba6d9 (patch)
tree2f589afcf9e3a4714828da32eb869f902e127c0c /Games/Chess/main.cpp
parent07badd953037b49ac754a644c59ae9531754fce1 (diff)
downloadserenity-172707a94585b739cfeef4aefdddb475ed2ba6d9.zip
Chess: Prevent board changes when waiting for ChessEngine to move
Diffstat (limited to 'Games/Chess/main.cpp')
-rw-r--r--Games/Chess/main.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/Games/Chess/main.cpp b/Games/Chess/main.cpp
index 150b25caaf..64545e944d 100644
--- a/Games/Chess/main.cpp
+++ b/Games/Chess/main.cpp
@@ -139,6 +139,10 @@ int main(int argc, char** argv)
app_menu.add_separator();
app_menu.add_action(GUI::Action::create("New game", { Mod_None, Key_F2 }, [&](auto&) {
+ if (widget.board().game_result() == Chess::Board::Result::NotFinished) {
+ if (widget.resign() < 0)
+ return;
+ }
widget.reset();
}));
app_menu.add_separator();
@@ -206,7 +210,7 @@ int main(int argc, char** argv)
widget.set_engine(nullptr);
} else {
widget.set_engine(Engine::construct(action.text()));
- widget.maybe_input_engine_move();
+ widget.input_engine_move();
}
});
engines_action_group.add_action(*action);