author | llornkcor <llornkcor> | 2004-04-26 10:24:35 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-04-26 10:24:35 (UTC) |
commit | f6a98984fcb0dfc7e176636560b7cc1adacf38f2 (patch) (unidiff) | |
tree | f358b16531551035a54c1dac95e16a36f86f8dc9 | |
parent | 57d7f3faf053786925d2315e43ab6ba8d892f51a (diff) | |
download | opie-f6a98984fcb0dfc7e176636560b7cc1adacf38f2.zip opie-f6a98984fcb0dfc7e176636560b7cc1adacf38f2.tar.gz opie-f6a98984fcb0dfc7e176636560b7cc1adacf38f2.tar.bz2 |
turn off silly casino rules solitare
-rw-r--r-- | noncore/games/solitaire/patiencecardgame.cpp | 13 | ||||
-rw-r--r-- | noncore/games/solitaire/patiencecardgame.h | 31 |
2 files changed, 25 insertions, 19 deletions
diff --git a/noncore/games/solitaire/patiencecardgame.cpp b/noncore/games/solitaire/patiencecardgame.cpp index 756577a..a1e4968 100644 --- a/noncore/games/solitaire/patiencecardgame.cpp +++ b/noncore/games/solitaire/patiencecardgame.cpp | |||
@@ -104,35 +104,35 @@ void PatienceCardGame::deal(void) | |||
104 | faceDownDealingPile->addCardToTop(card); | 104 | faceDownDealingPile->addCardToTop(card); |
105 | card->setCardPile( faceDownDealingPile ); | 105 | card->setCardPile( faceDownDealingPile ); |
106 | QPoint p = faceDownDealingPile->getCardPos( card ); | 106 | QPoint p = faceDownDealingPile->getCardPos( card ); |
107 | card->setPos( p.x(), p.y(), highestZ ); | 107 | card->setPos( p.x(), p.y(), highestZ ); |
108 | card->showCard(); | 108 | card->showCard(); |
109 | highestZ++; | 109 | highestZ++; |
110 | } | 110 | } |
111 | 111 | ||
112 | endDealing(); | 112 | endDealing(); |
113 | } | 113 | } |
114 | 114 | ||
115 | 115 | ||
116 | void PatienceCardGame::readConfig( Config& cfg ) | 116 | void PatienceCardGame::readConfig( Config& cfg ) |
117 | { | 117 | { |
118 | cfg.setGroup("GameState"); | 118 | cfg.setGroup("GameState"); |
119 | 119 | ||
120 | deckTurns = cfg.readNumEntry("DeckTurns", 2500); | ||
120 | // Do we have a config file to read in? | 121 | // Do we have a config file to read in? |
121 | if ( !cfg.hasKey("numberOfTimesThroughDeck") ) | 122 | if ( !cfg.hasKey("numberOfTimesThroughDeck") ) { |
122 | { | ||
123 | // if not, create a new game | 123 | // if not, create a new game |
124 | newGame(); | 124 | newGame(); |
125 | return; | 125 | return; |
126 | } | 126 | } |
127 | // We have a config file, lets read it in and use it | 127 | // We have a config file, lets read it in and use it |
128 | 128 | ||
129 | // Create Cards, but don't shuffle or deal them yet | 129 | // Create Cards, but don't shuffle or deal them yet |
130 | createDeck(); | 130 | createDeck(); |
131 | 131 | ||
132 | // How many times through the deck have we been | 132 | // How many times through the deck have we been |
133 | numberOfTimesThroughDeck = cfg.readNumEntry("numberOfTimesThroughDeck"); | 133 | numberOfTimesThroughDeck = cfg.readNumEntry("numberOfTimesThroughDeck"); |
134 | 134 | ||
135 | // restore state to the circle/cross under the dealing pile | 135 | // restore state to the circle/cross under the dealing pile |
136 | if ( canTurnOverDeck() ) | 136 | if ( canTurnOverDeck() ) |
137 | circleCross->setCircle(); | 137 | circleCross->setCircle(); |
138 | else | 138 | else |
@@ -264,16 +264,25 @@ void PatienceCardGame::mousePress(QPoint p) | |||
264 | card->setFace( FALSE ); | 264 | card->setFace( FALSE ); |
265 | faceUpDealingPile->removeCard( card ); | 265 | faceUpDealingPile->removeCard( card ); |
266 | faceDownDealingPile->addCardToTop( card ); | 266 | faceDownDealingPile->addCardToTop( card ); |
267 | card->setCardPile( faceDownDealingPile ); | 267 | card->setCardPile( faceDownDealingPile ); |
268 | card = faceUpDealingPile->cardOnTop(); | 268 | card = faceUpDealingPile->cardOnTop(); |
269 | highestZ++; | 269 | highestZ++; |
270 | } | 270 | } |
271 | endDealing(); | 271 | endDealing(); |
272 | 272 | ||
273 | throughDeck(); | 273 | throughDeck(); |
274 | 274 | ||
275 | moved = TRUE; | 275 | moved = TRUE; |
276 | } | 276 | } |
277 | } | 277 | } |
278 | 278 | ||
279 | 279 | ||
280 | bool PatienceCardGame::canTurnOverDeck() { | ||
281 | return (numberOfTimesThroughDeck != deckTurns); | ||
282 | } | ||
283 | |||
284 | void PatienceCardGame::throughDeck() { | ||
285 | numberOfTimesThroughDeck++; | ||
286 | if (numberOfTimesThroughDeck == deckTurns) | ||
287 | circleCross->setCross(); | ||
288 | } | ||
diff --git a/noncore/games/solitaire/patiencecardgame.h b/noncore/games/solitaire/patiencecardgame.h index 0d0e3d5..b76251a 100644 --- a/noncore/games/solitaire/patiencecardgame.h +++ b/noncore/games/solitaire/patiencecardgame.h | |||
@@ -5,125 +5,125 @@ | |||
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef PATIENCE_CARD_GAME_H | 20 | #ifndef PATIENCE_CARD_GAME_H |
21 | #define PATIENCE_CARD_GAME_H | 21 | #define PATIENCE_CARD_GAME_H |
22 | 22 | ||
23 | 23 | ||
24 | #include <qpopupmenu.h> | 24 | #include <qpopupmenu.h> |
25 | #include <qmainwindow.h> | 25 | #include <qmainwindow.h> |
26 | #include <qintdict.h> | 26 | #include <qintdict.h> |
27 | #include <qcanvas.h> | 27 | #include <qcanvas.h> |
28 | #include <qgfx_qws.h> | 28 | #include <qgfx_qws.h> |
29 | // #include "canvascardshapes.h" | 29 | // #include "canvascardshapes.h" |
30 | // #include "canvascard.h" | 30 | // #include "canvascard.h" |
31 | #include "canvascardgame.h" | 31 | #include "canvascardgame.h" |
32 | 32 | ||
33 | 33 | ||
34 | class PatienceFaceDownDeck : public CardPile, public CanvasRoundRect | 34 | class PatienceFaceDownDeck : public CardPile, public CanvasRoundRect |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | PatienceFaceDownDeck(int x, int y, QCanvas *canvas) | 37 | PatienceFaceDownDeck(int x, int y, QCanvas *canvas) |
38 | : CardPile(x, y), CanvasRoundRect(x, y, canvas) { } | 38 | : CardPile(x, y), CanvasRoundRect(x, y, canvas) { } |
39 | virtual bool isAllowedOnTop(Card *card) { | 39 | virtual bool isAllowedOnTop(Card *card) { |
40 | Q_UNUSED(card); | 40 | Q_UNUSED(card); |
41 | // Need to check it is from the faceUpDealingPile | 41 | // Need to check it is from the faceUpDealingPile |
42 | return TRUE; | 42 | return TRUE; |
43 | } | 43 | } |
44 | virtual bool isAllowedToBeMoved(Card *card) { | 44 | virtual bool isAllowedToBeMoved(Card *card) { |
45 | Q_UNUSED(card); | 45 | Q_UNUSED(card); |
46 | //if ( ( !card->isFacing() ) && ( card == cardOnTop() ) ) | 46 | //if ( ( !card->isFacing() ) && ( card == cardOnTop() ) ) |
47 | if ( card == cardOnTop() ) | 47 | if ( card == cardOnTop() ) |
48 | return TRUE; | 48 | return TRUE; |
49 | return FALSE; | 49 | return FALSE; |
50 | } | 50 | } |
51 | }; | 51 | }; |
52 | 52 | ||
53 | 53 | ||
54 | class PatienceFaceUpDeck : public CardPile, public CanvasRoundRect | 54 | class PatienceFaceUpDeck : public CardPile, public CanvasRoundRect |
55 | { | 55 | { |
56 | public: | 56 | public: |
57 | PatienceFaceUpDeck(int x, int y, QCanvas *canvas) | 57 | PatienceFaceUpDeck(int x, int y, QCanvas *canvas) |
58 | : CardPile(x, y), CanvasRoundRect(x, y, canvas) { } | 58 | : CardPile(x, y), CanvasRoundRect(x, y, canvas) { } |
59 | virtual bool isAllowedOnTop(Card *card) { | 59 | virtual bool isAllowedOnTop(Card *card) { |
60 | Q_UNUSED(card); | 60 | Q_UNUSED(card); |
61 | // Need to check it is from the faceDownDealingPile | 61 | // Need to check it is from the faceDownDealingPile |
62 | return TRUE; | 62 | return TRUE; |
63 | } | 63 | } |
64 | virtual bool isAllowedToBeMoved(Card *card) { | 64 | virtual bool isAllowedToBeMoved(Card *card) { |
65 | Q_UNUSED(card); | 65 | Q_UNUSED(card); |
66 | //if ( ( card->isFacing() ) && ( card == cardOnTop() ) ) | 66 | //if ( ( card->isFacing() ) && ( card == cardOnTop() ) ) |
67 | if ( card == cardOnTop() ) | 67 | if ( card == cardOnTop() ) |
68 | return TRUE; | 68 | return TRUE; |
69 | return FALSE; | 69 | return FALSE; |
70 | } | 70 | } |
71 | }; | 71 | }; |
72 | 72 | ||
73 | 73 | ||
74 | class PatienceDiscardPile : public CardPile, public CanvasRoundRect | 74 | class PatienceDiscardPile : public CardPile, public CanvasRoundRect |
75 | { | 75 | { |
76 | public: | 76 | public: |
77 | PatienceDiscardPile(int x, int y, QCanvas *canvas) | 77 | PatienceDiscardPile(int x, int y, QCanvas *canvas) |
78 | : CardPile(x, y), CanvasRoundRect(x, y, canvas) { } | 78 | : CardPile(x, y), CanvasRoundRect(x, y, canvas) { } |
79 | virtual bool isAllowedOnTop(Card *card) { | 79 | virtual bool isAllowedOnTop(Card *card) { |
80 | if ( card->isFacing() && ( card->getCardPile()->cardInfront(card) == NULL ) && | 80 | if ( card->isFacing() && ( card->getCardPile()->cardInfront(card) == NULL ) && |
81 | ( ( ( cardOnTop() == NULL ) && ( card->getValue() == ace ) ) || | 81 | ( ( ( cardOnTop() == NULL ) && ( card->getValue() == ace ) ) || |
82 | ( ( cardOnTop() != NULL ) && | 82 | ( ( cardOnTop() != NULL ) && |
83 | ( (int)card->getValue() == (int)cardOnTop()->getValue() + 1 ) && | 83 | ( (int)card->getValue() == (int)cardOnTop()->getValue() + 1 ) && |
84 | ( card->getSuit() == cardOnTop()->getSuit() ) ) ) ) | 84 | ( card->getSuit() == cardOnTop()->getSuit() ) ) ) ) |
85 | return TRUE; | 85 | return TRUE; |
86 | return FALSE; | 86 | return FALSE; |
87 | } | 87 | } |
88 | virtual bool isAllowedToBeMoved(Card *card) { | 88 | virtual bool isAllowedToBeMoved(Card *card) { |
89 | if ( card->isFacing() && ( card == cardOnTop() ) ) | 89 | if ( card->isFacing() && ( card == cardOnTop() ) ) |
90 | return TRUE; | 90 | return TRUE; |
91 | return FALSE; | 91 | return FALSE; |
92 | } | 92 | } |
93 | }; | 93 | }; |
94 | 94 | ||
95 | 95 | ||
96 | class PatienceWorkingPile : public CardPile, public CanvasRoundRect | 96 | class PatienceWorkingPile : public CardPile, public CanvasRoundRect |
97 | { | 97 | { |
98 | public: | 98 | public: |
99 | PatienceWorkingPile(int x, int y, QCanvas *canvas) | 99 | PatienceWorkingPile(int x, int y, QCanvas *canvas) |
100 | : CardPile(x, y), CanvasRoundRect(x, y, canvas), top(x, y) { } | 100 | : CardPile(x, y), CanvasRoundRect(x, y, canvas), top(x, y) { } |
101 | virtual bool isAllowedOnTop(Card *card) { | 101 | virtual bool isAllowedOnTop(Card *card) { |
102 | if ( card->isFacing() && | 102 | if ( card->isFacing() && |
103 | ( ( ( cardOnTop() == NULL ) && (card->getValue() == king) ) || | 103 | ( ( ( cardOnTop() == NULL ) && (card->getValue() == king) ) || |
104 | ( ( cardOnTop() != NULL ) && | 104 | ( ( cardOnTop() != NULL ) && |
105 | ( (int)card->getValue() + 1 == (int)cardOnTop()->getValue() ) && | 105 | ( (int)card->getValue() + 1 == (int)cardOnTop()->getValue() ) && |
106 | ( card->isRed() != cardOnTop()->isRed() ) ) ) ) | 106 | ( card->isRed() != cardOnTop()->isRed() ) ) ) ) |
107 | return TRUE; | 107 | return TRUE; |
108 | return FALSE; | 108 | return FALSE; |
109 | } | 109 | } |
110 | virtual bool isAllowedToBeMoved(Card *card) { | 110 | virtual bool isAllowedToBeMoved(Card *card) { |
111 | if ( card->isFacing() ) | 111 | if ( card->isFacing() ) |
112 | return TRUE; | 112 | return TRUE; |
113 | return FALSE; | 113 | return FALSE; |
114 | } | 114 | } |
115 | virtual void cardAddedToTop(Card *card) { | 115 | virtual void cardAddedToTop(Card *card) { |
116 | Q_UNUSED(card); | 116 | Q_UNUSED(card); |
117 | top = getCardPos(NULL); | 117 | top = getCardPos(NULL); |
118 | setNextX( top.x() ); | 118 | setNextX( top.x() ); |
119 | setNextY( top.y() ); | 119 | setNextY( top.y() ); |
120 | } | 120 | } |
121 | virtual void cardRemoved(Card *card) { | 121 | virtual void cardRemoved(Card *card) { |
122 | Q_UNUSED(card); | 122 | Q_UNUSED(card); |
123 | 123 | ||
124 | Card *newTopCard = cardOnTop(); | 124 | Card *newTopCard = cardOnTop(); |
125 | 125 | ||
126 | if ( !newTopCard ) { | 126 | if ( !newTopCard ) { |
127 | top = QPoint( pileX, pileY ); | 127 | top = QPoint( pileX, pileY ); |
128 | setNextX( pileX ); | 128 | setNextX( pileX ); |
129 | setNextY( pileY ); | 129 | setNextY( pileY ); |
@@ -135,75 +135,72 @@ public: | |||
135 | // correct the position taking in to account the card is not | 135 | // correct the position taking in to account the card is not |
136 | // yet flipped, but will become flipped | 136 | // yet flipped, but will become flipped |
137 | top = QPoint( top.x() - 1, top.y() - 3 ); | 137 | top = QPoint( top.x() - 1, top.y() - 3 ); |
138 | newTopCard->flipTo( top.x(), top.y() ); | 138 | newTopCard->flipTo( top.x(), top.y() ); |
139 | top = QPoint( top.x(), top.y() + offsetDown ); | 139 | top = QPoint( top.x(), top.y() + offsetDown ); |
140 | } | 140 | } |
141 | setNextX( top.x() ); | 141 | setNextX( top.x() ); |
142 | setNextY( top.y() ); | 142 | setNextY( top.y() ); |
143 | } | 143 | } |
144 | } | 144 | } |
145 | virtual QPoint getCardPos(Card *c) { | 145 | virtual QPoint getCardPos(Card *c) { |
146 | int x = pileX, y = pileY; | 146 | int x = pileX, y = pileY; |
147 | Card *card = cardOnBottom(); | 147 | Card *card = cardOnBottom(); |
148 | while ((card != c) && (card != NULL)) { | 148 | while ((card != c) && (card != NULL)) { |
149 | if (card->isFacing()) { | 149 | if (card->isFacing()) { |
150 | int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; | 150 | int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; |
151 | y += offsetDown; | 151 | y += offsetDown; |
152 | } else { | 152 | } else { |
153 | x += 1; | 153 | x += 1; |
154 | y += 3; | 154 | y += 3; |
155 | } | 155 | } |
156 | card = cardInfront(card); | 156 | card = cardInfront(card); |
157 | } | 157 | } |
158 | return QPoint( x, y ); | 158 | return QPoint( x, y ); |
159 | } | 159 | } |
160 | virtual QPoint getHypertheticalNextCardPos(void) { | 160 | virtual QPoint getHypertheticalNextCardPos(void) { |
161 | return top; | 161 | return top; |
162 | // return QPoint( getNextX(), getNextY() ); | 162 | // return QPoint( getNextX(), getNextY() ); |
163 | } | 163 | } |
164 | private: | 164 | private: |
165 | QPoint top; | 165 | QPoint top; |
166 | 166 | ||
167 | }; | 167 | }; |
168 | 168 | ||
169 | 169 | ||
170 | class PatienceCardGame : public CanvasCardGame | 170 | class PatienceCardGame : public CanvasCardGame |
171 | { | 171 | { |
172 | public: | 172 | public: |
173 | PatienceCardGame(QCanvas *c, bool snap, QWidget *parent = 0); | 173 | PatienceCardGame(QCanvas *c, bool snap, QWidget *parent = 0); |
174 | virtual ~PatienceCardGame(); | 174 | virtual ~PatienceCardGame(); |
175 | virtual void deal(void); | 175 | virtual void deal(void); |
176 | virtual bool haveWeWon() { | 176 | int deckTurns; |
177 | virtual bool haveWeWon() { | ||
177 | return ( discardPiles[0]->kingOnTop() && | 178 | return ( discardPiles[0]->kingOnTop() && |
178 | discardPiles[1]->kingOnTop() && | 179 | discardPiles[1]->kingOnTop() && |
179 | discardPiles[2]->kingOnTop() && | 180 | discardPiles[2]->kingOnTop() && |
180 | discardPiles[3]->kingOnTop() );; | 181 | discardPiles[3]->kingOnTop() );; |
181 | } | 182 | } |
182 | virtual void mousePress(QPoint p); | 183 | virtual void mousePress(QPoint p); |
183 | virtual void mouseRelease(QPoint p) { Q_UNUSED(p); } | 184 | virtual void mouseRelease(QPoint p) { Q_UNUSED(p); } |
184 | // virtual void mouseMove(QPoint p); | 185 | // virtual void mouseMove(QPoint p); |
185 | virtual bool mousePressCard(Card *card, QPoint p); | 186 | virtual bool mousePressCard(Card *card, QPoint p); |
186 | virtual void mouseReleaseCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); } | 187 | virtual void mouseReleaseCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); } |
187 | // virtual void mouseMoveCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); } | 188 | // virtual void mouseMoveCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); } |
188 | bool canTurnOverDeck(void) { return (numberOfTimesThroughDeck != 3); } | 189 | bool canTurnOverDeck(); |
189 | void throughDeck(void) { | 190 | void throughDeck(); |
190 | numberOfTimesThroughDeck++; | ||
191 | if (numberOfTimesThroughDeck == 3) | ||
192 | circleCross->setCross(); | ||
193 | } | ||
194 | bool snapOn; | 191 | bool snapOn; |
195 | virtual void writeConfig( Config& cfg ); | 192 | virtual void writeConfig( Config& cfg ); |
196 | virtual void readConfig( Config& cfg ); | 193 | virtual void readConfig( Config& cfg ); |
197 | private: | 194 | private: |
198 | CanvasCircleOrCross *circleCross; | 195 | CanvasCircleOrCross *circleCross; |
199 | CanvasRoundRect *rectangle; | 196 | CanvasRoundRect *rectangle; |
200 | PatienceWorkingPile *workingPiles[7]; | 197 | PatienceWorkingPile *workingPiles[7]; |
201 | PatienceDiscardPile *discardPiles[4]; | 198 | PatienceDiscardPile *discardPiles[4]; |
202 | PatienceFaceDownDeck *faceDownDealingPile; | 199 | PatienceFaceDownDeck *faceDownDealingPile; |
203 | PatienceFaceUpDeck *faceUpDealingPile; | 200 | PatienceFaceUpDeck *faceUpDealingPile; |
204 | int numberOfTimesThroughDeck; | 201 | int numberOfTimesThroughDeck; |
205 | }; | 202 | }; |
206 | 203 | ||
207 | 204 | ||
208 | #endif | 205 | #endif |
209 | 206 | ||