mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:17:35 +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:
parent
ac1eba2f7c
commit
e636ed43eb
2 changed files with 15 additions and 1 deletions
|
@ -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();
|
||||
|
|
|
@ -77,6 +77,8 @@ private:
|
|||
PassingSelectConfirmed,
|
||||
PassingAccept,
|
||||
Play,
|
||||
GameEndedWaiting,
|
||||
GameEnded,
|
||||
};
|
||||
|
||||
State m_state { State::PassingSelect };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue