Return bool (success status) from drawNextCard

This commit is contained in:
ItsDrike 2024-12-06 04:54:34 +01:00
parent 206ff25a1a
commit eec98ba110
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
2 changed files with 4 additions and 3 deletions

View file

@ -89,14 +89,14 @@ void GameState::setupWinningDeck() {
emit foundationChanged(); emit foundationChanged();
} }
void GameState::drawNextCard() { bool GameState::drawNextCard() {
qDebug() << "Drawing next card."; qDebug() << "Drawing next card.";
// If drawPile is empty, flip the throwawayPile to drawPile // If drawPile is empty, flip the throwawayPile to drawPile
if (m_drawPile.isEmpty()) { if (m_drawPile.isEmpty()) {
if (m_throwawayPile.isEmpty()) { if (m_throwawayPile.isEmpty()) {
qWarning() << "Drawing a card failed, no more cards to draw from"; qWarning() << "Drawing a card failed, no more cards to draw from";
return; return false;
} }
m_drawPile = m_throwawayPile; m_drawPile = m_throwawayPile;
m_throwawayPile.clear(); m_throwawayPile.clear();
@ -110,6 +110,7 @@ void GameState::drawNextCard() {
emit drawPileChanged(); emit drawPileChanged();
emit throwawayPileChanged(); emit throwawayPileChanged();
return true;
} }
bool GameState::moveThrownCardToColumn(int columnId) { bool GameState::moveThrownCardToColumn(int columnId) {

View file

@ -30,7 +30,7 @@ class GameState : public QObject {
// General functions // General functions
Q_INVOKABLE void dealCards(); Q_INVOKABLE void dealCards();
Q_INVOKABLE void setupWinningDeck(); Q_INVOKABLE void setupWinningDeck();
Q_INVOKABLE void drawNextCard(); Q_INVOKABLE bool drawNextCard();
// Manual moves (from X to Y) // Manual moves (from X to Y)
Q_INVOKABLE bool moveThrownCardToColumn(int columnId); Q_INVOKABLE bool moveThrownCardToColumn(int columnId);