From 5a2e7d5465533df7978d134eec8b59390b05965b Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 9 Dec 2024 23:27:05 +0100 Subject: [PATCH] Improve preliminary win check --- src/gamestate.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/gamestate.cpp b/src/gamestate.cpp index 789e99e..9247222 100644 --- a/src/gamestate.cpp +++ b/src/gamestate.cpp @@ -633,22 +633,22 @@ void GameState::incrementMoveAmt() { bool GameState::prelimWinCheck() { // Check if the game is preliminarily won: - // This occurs when there are no cards in the draw or throwaway piles, - // and all cards in the tableau are revealed. Such games are essentially won, - // as the cards only need to be moved to the foundation piles. - bool prelimWin = m_drawPile.isEmpty() && m_throwawayPile.isEmpty(); + // This occurs when all cards in the tableau are revealed. + // Games in this state are essentially won, as the cards + // only need to be moved to the foundation piles. - if (prelimWin) { - for (const auto& column : std::as_const(m_columns)) { - for (const ColumnSlot* card : column) { - if (!card->isRevealed()) { - prelimWin = false; - break; - } - } - if (!prelimWin) + bool prelimWin = true; // Assume a preliminary win unless proven otherwise. + + // Check if all tableau cards are revealed + for (const auto& column : std::as_const(m_columns)) { + for (const ColumnSlot* card : column) { + if (!card->isRevealed()) { + prelimWin = false; break; + } } + if (!prelimWin) + break; } if (prelimWin == m_prelimWin)