From eec98ba110ccdb1c7b509cb49220681d43d53701 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 6 Dec 2024 04:54:34 +0100 Subject: [PATCH] Return bool (success status) from drawNextCard --- src/gamestate.cpp | 5 +++-- src/gamestate.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gamestate.cpp b/src/gamestate.cpp index a6229fa..71640fe 100644 --- a/src/gamestate.cpp +++ b/src/gamestate.cpp @@ -89,14 +89,14 @@ void GameState::setupWinningDeck() { emit foundationChanged(); } -void GameState::drawNextCard() { +bool GameState::drawNextCard() { qDebug() << "Drawing next card."; // If drawPile is empty, flip the throwawayPile to drawPile if (m_drawPile.isEmpty()) { if (m_throwawayPile.isEmpty()) { qWarning() << "Drawing a card failed, no more cards to draw from"; - return; + return false; } m_drawPile = m_throwawayPile; m_throwawayPile.clear(); @@ -110,6 +110,7 @@ void GameState::drawNextCard() { emit drawPileChanged(); emit throwawayPileChanged(); + return true; } bool GameState::moveThrownCardToColumn(int columnId) { diff --git a/src/gamestate.h b/src/gamestate.h index e44df58..04d5f1d 100644 --- a/src/gamestate.h +++ b/src/gamestate.h @@ -30,7 +30,7 @@ class GameState : public QObject { // General functions Q_INVOKABLE void dealCards(); Q_INVOKABLE void setupWinningDeck(); - Q_INVOKABLE void drawNextCard(); + Q_INVOKABLE bool drawNextCard(); // Manual moves (from X to Y) Q_INVOKABLE bool moveThrownCardToColumn(int columnId);