00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef CARD_H
00021 #define CARD_H
00022
00023
00024 #include <qpoint.h>
00025
00026
00027 class CardPile;
00028
00029
00030 enum eSuit {
00031 jokerSuit = 0, clubs, spades, diamonds, hearts
00032 };
00033
00034
00035 enum eValue {
00036 jokerVal = 0, ace, two, three, four, five,
00037 six, seven, eight, nine, ten, jack, queen, king
00038 };
00039
00040
00041 class Card
00042 {
00043 public:
00044 Card( eValue v, eSuit s, bool f ) :
00045 val(v), suit(s), faceUp(f), showing(FALSE), ix(0), iy(0), iz(0), cardPile(NULL) { }
00046 virtual ~Card() { }
00047
00048 eValue getValue() { return val; }
00049 eSuit getSuit() { return suit; }
00050
00051 void setCardPile(CardPile *p) { cardPile = p; }
00052 CardPile *getCardPile() { return cardPile; }
00053
00054 void setFace(bool f) { faceUp = f; }
00055 bool isFacing() { return faceUp; }
00056
00057 bool isShowing() { return showing; }
00058 bool isRed() { return ((suit == diamonds) || (suit == hearts)); }
00059
00060 int getDeckNumber() { return deckNumber; }
00061 void setDeckNumber(int n) { deckNumber=n; }
00062
00063 int getX(void) { return ix; }
00064 int getY(void) { return iy; }
00065 int getZ(void) { return iz; }
00066 void flip(void) { flipTo(getX(), getY()); }
00067
00068 virtual void setPos(int x, int y, int z) { ix = x; iy = y; iz = z; }
00069 virtual void move(int x, int y) { ix = x; iy = y; }
00070 virtual void move(QPoint p) { ix = p.x(); iy = p.y(); }
00071 virtual void flipTo(int x, int y, int steps = 8) { ix = x; iy = y; faceUp = !faceUp; redraw(); Q_UNUSED(steps); }
00072 virtual void showCard(void) { showing = TRUE; }
00073 virtual void hideCard(void) { showing = FALSE; }
00074 protected:
00075 virtual void redraw(void) { }
00076 private:
00077 eValue val;
00078 eSuit suit;
00079 bool faceUp;
00080 bool showing;
00081 int deckNumber;
00082 int ix, iy, iz;
00083 CardPile *cardPile;
00084 };
00085
00086
00087 #endif
00088