summaryrefslogtreecommitdiff
path: root/noncore/games/solitaire/cardpile.h
authorkergoth <kergoth>2002-01-25 22:14:26 (UTC)
committer kergoth <kergoth>2002-01-25 22:14:26 (UTC)
commit15318cad33835e4e2dc620d033e43cd930676cdd (patch) (unidiff)
treec2fa0399a2c47fda8e2cd0092c73a809d17f68eb /noncore/games/solitaire/cardpile.h
downloadopie-15318cad33835e4e2dc620d033e43cd930676cdd.zip
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2
Initial revision
Diffstat (limited to 'noncore/games/solitaire/cardpile.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/solitaire/cardpile.h101
1 files changed, 101 insertions, 0 deletions
diff --git a/noncore/games/solitaire/cardpile.h b/noncore/games/solitaire/cardpile.h
new file mode 100644
index 0000000..c515bbc
--- a/dev/null
+++ b/noncore/games/solitaire/cardpile.h
@@ -0,0 +1,101 @@
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_PILE_H
21#define CARD_PILE_H
22
23
24#include <qpoint.h>
25#include <qlist.h>
26
27
28enum ePileStackingType {
29 pileCascades = 0, pileStacks, pileCascadesOrStacks
30};
31
32
33enum ePileFaceingType {
34 pileFaceUp = 0, pileFaceDown, pileFaceUpOrDown
35};
36
37
38class Card;
39class Config;
40
41
42class CardPile : public QList<Card>
43{
44public:
45 CardPile(int x, int y);
46 virtual ~CardPile() { }
47
48 int getX() { return pileX; }
49 int getY() { return pileY; }
50 int getNextX() { return pileNextX; }
51 int getNextY() { return pileNextY; }
52 int getWidth() { return pileWidth; }
53 int getHeight() { return pileHeight; }
54
55 void setX(int x) { pileX = x; }
56 void setY(int y) { pileY = y; }
57 void setNextX(int x) { pileNextX = x; }
58 void setNextY(int y) { pileNextY = y; }
59 void setWidth(int width) { pileWidth = width; }
60 void setHeight(int height) { pileHeight = height; }
61
62 void beginDealing() { dealing = TRUE; }
63 void endDealing() { dealing = FALSE; }
64 bool isDealing() { return dealing; }
65
66 int distanceFromPile(int x, int y);
67 int distanceFromNextPos(int x, int y);
68
69 Card *cardOnTop() { return getLast(); }
70 Card *cardOnBottom() { return getFirst(); }
71 Card *cardInfront(Card *c);
72 bool kingOnTop();
73
74 bool addCardToTop(Card *c);
75 bool addCardToBottom(Card *c);
76 bool removeCard(Card *c);
77
78 virtual void cardAddedToTop(Card *) { }
79 virtual void cardAddedToBottom(Card *) { }
80 virtual void cardRemoved(Card *) { }
81 virtual bool isAllowedOnTop(Card *) { return FALSE; }
82 virtual bool isAllowedOnBottom(Card *) { return FALSE; }
83 virtual bool isAllowedToBeMoved(Card *) { return FALSE; }
84 virtual QPoint getCardPos(Card *) { return QPoint(pileX, pileY); }
85 virtual QPoint getHypertheticalNextCardPos() { return QPoint(pileX, pileY); }
86
87 void writeConfig( Config& cfg, QString name );
88
89protected:
90 int pileX, pileY;
91 int pileNextX, pileNextY;
92 int pileWidth, pileHeight;
93 int pileCenterX, pileCenterY;
94 int pileRadius;
95private:
96 bool dealing;
97};
98
99
100#endif
101