solitare/gamestate.h

47 lines
1.5 KiB
C
Raw Normal View History

2024-12-01 21:40:42 +00:00
#ifndef GAMESTATE_H
#define GAMESTATE_H
#include <QObject>
#include "playingcard.h"
2024-12-02 15:10:51 +00:00
#include "columnslot.h"
2024-12-01 21:40:42 +00:00
class GameState : public QObject
{
Q_OBJECT
Q_PROPERTY(QList<PlayingCard*> drawPile READ drawPile NOTIFY onDrawPileChanged)
Q_PROPERTY(QList<PlayingCard*> throwawayPile READ throwawayPile NOTIFY onThrowawayPileChanged)
2024-12-02 15:10:51 +00:00
Q_PROPERTY(QList<QList<ColumnSlot*>> columns READ columns NOTIFY onColumnsChanged)
2024-12-01 21:40:42 +00:00
Q_PROPERTY(QList<QList<PlayingCard*>> foundation READ foundation NOTIFY onFoundationChanged)
public:
explicit GameState(QObject *parent = nullptr);
QList<PlayingCard*> drawPile() const;
QList<PlayingCard*> throwawayPile() const;
2024-12-02 15:10:51 +00:00
QList<QList<ColumnSlot*>> columns() const;
2024-12-01 21:40:42 +00:00
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;
2024-12-02 15:10:51 +00:00
QList<QList<ColumnSlot*>> m_columns;
2024-12-01 21:40:42 +00:00
QList<QList<PlayingCard*>> m_foundation;
bool tryMoveCardToFoundation(PlayingCard::Suit foundationId, PlayingCard* cardToMove);
2024-12-02 15:10:51 +00:00
void ensureColumnRevealed(int columnId);
2024-12-01 21:40:42 +00:00
};
#endif // GAMESTATE_H