-
Notifications
You must be signed in to change notification settings - Fork 0
/
card.h
71 lines (62 loc) · 2.01 KB
/
card.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef CARD_H
#define CARD_H
#include <QImage>
#include <QLabel>
#include <QMouseEvent>
#include "pile.h"
#include "move.h"
#include <QStack>
#include <QList>
#include <QStack>
enum cardColors {BLACK, RED};
enum pips {ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING};
enum suits {CLUBS, DIAMONDS, HEARTS, SPADES };
class card: public QLabel
{
private:
static QImage faces[54];
static bool initialized;
static QPoint mouseDownOffset; //initialized on mouse down event
static QPoint startDragPos;
static bool buttonDown;
static QPoint popUpPos;
static card* popUpCard;
card* over; //card that is over it on the pile
card* under; //card that is under it on the pile
Pile *on;
pips pip;
suits suit;
cardColors cardColor;
int value; //0 to 51 to get the image of the card
int id;
public:
card(pips p, suits s, int v, int id, QWidget* parent);
~card();
bool faceup;
QList<Pile*>* piles;
static void Initialize();
pips getPip(){return pip;}
suits getSuit(){return suit;}
cardColors getColor(){return cardColor;}
card* getOver(){return over;}
void setOver(card* c){over = c;}
void setUnder(card* c){under = c;}
void setPile(Pile* p);
void setImage();
int getId(){return id;}
void mousePressEvent(QMouseEvent* ev);
void mouseReleaseEvent(QMouseEvent* ev);
void mouseMoveEvent(QMouseEvent* ev);
void mouseDoubleClickEvent(QMouseEvent* ev);
bool okTodrag(Pile* pile); // check if cards can be dragged
void setFaceUp(){faceup = true; setImage();}
void setFaceDown(){faceup = false;}
bool isfaceup(){return faceup;}
void winCheck();
void sequenceCheck(Pile* piles); // for spider, checks if a sequence from Ace to King was made. If yes send it to stock pile
void refill(); //for klondike, when the cards are over on the deck, refill it.
QStack<Move>* history; //record movements
void setHistory(QStack<Move>* h){history = h;}
friend class Pile;
};
#endif // CARD_H