summaryrefslogtreecommitdiff
path: root/noncore/games/solitaire/card.h
Unidiff
Diffstat (limited to 'noncore/games/solitaire/card.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/solitaire/card.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/noncore/games/solitaire/card.h b/noncore/games/solitaire/card.h
new file mode 100644
index 0000000..eb30d30
--- a/dev/null
+++ b/noncore/games/solitaire/card.h
@@ -0,0 +1,84 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef CARD_H
21#define CARD_H
22
23
24#include <qpoint.h>
25
26
27class CardPile;
28
29
30enum eSuit {
31 jokerSuit = 0, clubs, spades, diamonds, hearts
32};
33
34
35enum eValue {
36 jokerVal = 0, ace, two, three, four, five,
37 six, seven, eight, nine, ten, jack, queen, king
38};
39
40
41class Card
42{
43public:
44 Card( eValue v, eSuit s, bool f ) :
45 val(v), suit(s), faceUp(f), showing(FALSE), ix(0), iy(0), iz(0), cardPile(NULL) { }
46 virtual ~Card() { }
47
48 eValue getValue() { return val; }
49 eSuit getSuit() { return suit; }
50
51 void setCardPile(CardPile *p) { cardPile = p; }
52 CardPile *getCardPile() { return cardPile; }
53
54 void setFace(bool f) { faceUp = f; /* flip(); */ }
55 bool isFacing() { return faceUp; }
56
57 bool isShowing() { return showing; }
58 bool isRed() { return ((suit == diamonds) || (suit == hearts)); }
59
60 int getX(void) { return ix; }
61 int getY(void) { return iy; }
62 int getZ(void) { return iz; }
63 void flip(void) { flipTo(getX(), getY()); }
64
65 virtual void setPos(int x, int y, int z) { ix = x; iy = y; iz = z; }
66 virtual void move(int x, int y) { ix = x; iy = y; }
67 virtual void move(QPoint p) { ix = p.x(); iy = p.y(); }
68 virtual void flipTo(int x, int y, int steps = 8) { ix = x; iy = y; faceUp = !faceUp; redraw(); Q_UNUSED(steps); }
69 virtual void showCard(void) { showing = TRUE; }
70 virtual void hideCard(void) { showing = FALSE; }
71protected:
72 virtual void redraw(void) { }
73private:
74 eValue val;
75 eSuit suit;
76 bool faceUp;
77 bool showing;
78 int ix, iy, iz;
79 CardPile *cardPile;
80};
81
82
83#endif
84