45 lines
1.4 KiB
C++
45 lines
1.4 KiB
C++
#ifndef GAMESTATE_H
|
|
#define GAMESTATE_H
|
|
|
|
#include <QObject>
|
|
#include "playingcard.h"
|
|
|
|
class GameState : public QObject
|
|
{
|
|
Q_OBJECT
|
|
Q_PROPERTY(QList<PlayingCard*> drawPile READ drawPile NOTIFY onDrawPileChanged)
|
|
Q_PROPERTY(QList<PlayingCard*> throwawayPile READ throwawayPile NOTIFY onThrowawayPileChanged)
|
|
Q_PROPERTY(QList<QList<PlayingCard*>> columns READ columns NOTIFY onColumnsChanged)
|
|
Q_PROPERTY(QList<QList<PlayingCard*>> foundation READ foundation NOTIFY onFoundationChanged)
|
|
|
|
public:
|
|
explicit GameState(QObject *parent = nullptr);
|
|
|
|
QList<PlayingCard*> drawPile() const;
|
|
QList<PlayingCard*> throwawayPile() const;
|
|
QList<QList<PlayingCard*>> columns() const;
|
|
QList<QList<PlayingCard*>> foundation() const;
|
|
|
|
void dealCards();
|
|
void drawNextCard();
|
|
bool moveCardToColumn(int columnId);
|
|
bool moveThrownCardToFoundation(PlayingCard::Suit foundationId);
|
|
bool moveColumnCardToFoundation(int columnId, PlayingCard::Suit foundationId);
|
|
|
|
signals:
|
|
void onDrawPileChanged();
|
|
void onThrowawayPileChanged();
|
|
void onColumnsChanged();
|
|
void onFoundationChanged();
|
|
|
|
private:
|
|
QList<PlayingCard*> m_drawPile;
|
|
QList<PlayingCard*> m_throwawayPile;
|
|
QList<QList<PlayingCard*>> m_columns;
|
|
QList<QList<PlayingCard*>> m_foundation;
|
|
|
|
bool tryMoveCardToFoundation(PlayingCard::Suit foundationId, PlayingCard* cardToMove);
|
|
};
|
|
|
|
#endif // GAMESTATE_H
|