solitare/playingcard.h

72 lines
1.5 KiB
C
Raw Normal View History

2024-12-01 18:43:49 +00:00
#ifndef PLAYINGCARD_H
#define PLAYINGCARD_H
#include <QObject>
class PlayingCard : public QObject
{
Q_OBJECT
Q_ENUMS(Value)
Q_ENUMS(Suit)
Q_PROPERTY(Suit suit READ suit WRITE setSuit NOTIFY onSuitChanged REQUIRED)
Q_PROPERTY(Value value READ value WRITE setValue NOTIFY onValueChanged REQUIRED)
2024-12-01 18:43:49 +00:00
Q_PROPERTY(bool isFaceDown READ isFaceDown WRITE setIsFaceDown NOTIFY onIsFaceDownChanged)
Q_PROPERTY(QString valueString READ valueString NOTIFY onValueChanged)
Q_PROPERTY(QString suitString READ suitString NOTIFY onSuitChanged)
2024-12-01 18:43:49 +00:00
public:
enum Value {
Ace = 1,
Two = 2,
Three = 3,
Four = 4,
Five = 5,
Six = 6,
Seven = 7,
Eight = 8,
Nine = 9,
Ten = 10,
Jack = 11,
Queen = 12,
King = 13,
};
2024-12-01 18:43:49 +00:00
enum Suit {
Clubs,
Diamonds,
Hearts,
Spades,
};
2024-12-01 18:43:49 +00:00
explicit PlayingCard(const Suit &suit = Suit::Clubs, const Value &value = Value::Ace, bool isFaceDown = false, QObject *parent = nullptr);
Suit suit() const;
QString suitString() const;
void setSuit(const Suit &suit);
Value value() const;
QString valueString() const;
void setValue(const Value &value);
2024-12-01 18:43:49 +00:00
bool isFaceDown() const;
void setIsFaceDown(bool faceDown);
static QList<PlayingCard*> createDeck();
2024-12-01 18:43:49 +00:00
signals:
void onSuitChanged();
2024-12-01 18:43:49 +00:00
void onValueChanged();
void onIsFaceDownChanged();
private:
Suit m_suit;
Value m_value;
2024-12-01 18:43:49 +00:00
bool m_isFaceDown;
QString m_imgUrl;
};
#endif // PLAYINGCARD_H