1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:17:44 +00:00

Hearts: Let the AI continuously play games

When there are no human players (toggled with Shift-F10) the AI will
continuously start new games when the current game has finished.
This commit is contained in:
Gunnar Beutner 2021-05-24 17:27:26 +02:00 committed by Andreas Kling
parent ac1eba2f7c
commit e636ed43eb
2 changed files with 15 additions and 1 deletions

View file

@ -337,11 +337,23 @@ void Game::continue_game_after_delay(int interval_ms)
void Game::advance_game()
{
if (game_ended()) {
if (m_state == State::Play && game_ended()) {
m_state = State::GameEndedWaiting;
on_status_change("Game ended.");
continue_game_after_delay(2000);
return;
}
if (m_state == State::GameEndedWaiting) {
m_state = State::GameEnded;
if (!m_players[0].is_human)
setup(move(m_players[0].name));
return;
}
if (m_state == State::GameEnded)
return;
if (m_state == State::PassingSelect) {
if (!m_players[0].is_human) {
select_cards_for_passing();