summaryrefslogtreecommitdiff
path: root/noncore
authorllornkcor <llornkcor>2004-04-26 10:24:35 (UTC)
committer llornkcor <llornkcor>2004-04-26 10:24:35 (UTC)
commitf6a98984fcb0dfc7e176636560b7cc1adacf38f2 (patch) (unidiff)
treef358b16531551035a54c1dac95e16a36f86f8dc9 /noncore
parent57d7f3faf053786925d2315e43ab6ba8d892f51a (diff)
downloadopie-f6a98984fcb0dfc7e176636560b7cc1adacf38f2.zip
opie-f6a98984fcb0dfc7e176636560b7cc1adacf38f2.tar.gz
opie-f6a98984fcb0dfc7e176636560b7cc1adacf38f2.tar.bz2
turn off silly casino rules solitare
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/solitaire/patiencecardgame.cpp13
-rw-r--r--noncore/games/solitaire/patiencecardgame.h31
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
@@ -114,15 +114,15 @@ void PatienceCardGame::deal(void)
114 114
115 115
116void PatienceCardGame::readConfig( Config& cfg ) 116void 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
@@ -274,6 +274,15 @@ void PatienceCardGame::mousePress(QPoint p)
274 274
275 moved = TRUE; 275 moved = TRUE;
276 } 276 }
277} 277}
278 278
279 279
280bool PatienceCardGame::canTurnOverDeck() {
281 return (numberOfTimesThroughDeck != deckTurns);
282}
283
284void 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
@@ -15,13 +15,13 @@
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>
@@ -43,13 +43,13 @@ public:
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
54class PatienceFaceUpDeck : public CardPile, public CanvasRoundRect 54class PatienceFaceUpDeck : public CardPile, public CanvasRoundRect
55{ 55{
@@ -63,13 +63,13 @@ public:
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
74class PatienceDiscardPile : public CardPile, public CanvasRoundRect 74class PatienceDiscardPile : public CardPile, public CanvasRoundRect
75{ 75{
@@ -80,18 +80,18 @@ public:
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
96class PatienceWorkingPile : public CardPile, public CanvasRoundRect 96class PatienceWorkingPile : public CardPile, public CanvasRoundRect
97{ 97{
@@ -102,18 +102,18 @@ public:
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() );
@@ -145,18 +145,18 @@ public:
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() );
@@ -170,30 +170,27 @@ private:
170class PatienceCardGame : public CanvasCardGame 170class PatienceCardGame : public CanvasCardGame
171{ 171{
172public: 172public:
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 );
197private: 194private:
198 CanvasCircleOrCross *circleCross; 195 CanvasCircleOrCross *circleCross;
199 CanvasRoundRect *rectangle; 196 CanvasRoundRect *rectangle;