summaryrefslogtreecommitdiff
authortille <tille>2002-07-10 13:58:19 (UTC)
committer tille <tille>2002-07-10 13:58:19 (UTC)
commit6fefe6d5f0b7721e8f692ad8759666f3c50cd437 (patch) (unidiff)
treefa55166dba5b4366479a9c96c9efcc35a4ab7a02
parentdcf25882f9093a34571454ec7bb2ecb821575498 (diff)
downloadopie-6fefe6d5f0b7721e8f692ad8759666f3c50cd437.zip
opie-6fefe6d5f0b7721e8f692ad8759666f3c50cd437.tar.gz
opie-6fefe6d5f0b7721e8f692ad8759666f3c50cd437.tar.bz2
tr(comments)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/solitaire/canvascardgame.cpp4
-rw-r--r--noncore/games/solitaire/chicanecardgame.cpp8
-rw-r--r--noncore/games/solitaire/chicanecardgame.h17
-rw-r--r--noncore/games/solitaire/harpcardgame.cpp10
-rw-r--r--noncore/games/solitaire/harpcardgame.h18
-rw-r--r--noncore/games/solitaire/teeclubcardgame.cpp12
-rw-r--r--noncore/games/solitaire/teeclubcardgame.h27
7 files changed, 74 insertions, 22 deletions
diff --git a/noncore/games/solitaire/canvascardgame.cpp b/noncore/games/solitaire/canvascardgame.cpp
index 4404b04..8e07cc8 100644
--- a/noncore/games/solitaire/canvascardgame.cpp
+++ b/noncore/games/solitaire/canvascardgame.cpp
@@ -330,58 +330,58 @@ void CanvasCardGame::contentsMouseReleaseEvent(QMouseEvent *e)
330 pile->addCardToTop(item); 330 pile->addCardToTop(item);
331 item->setCardPile(pile); 331 item->setCardPile(pile);
332 //item->move( pile->getCardPos(item) ); 332 //item->move( pile->getCardPos(item) );
333 QPoint p = pile->getCardPos(item); 333 QPoint p = pile->getCardPos(item);
334 item->setPos( p.x(), p.y(), highestZ ); 334 item->setPos( p.x(), p.y(), highestZ );
335 highestZ++; 335 highestZ++;
336 336
337 if (item->getValue() == king && haveWeWon()) { 337 if (item->getValue() == king && haveWeWon()) {
338 alphaCardPile->hide(); 338 alphaCardPile->hide();
339 gameWon(); 339 gameWon();
340 moving = NULL; 340 moving = NULL;
341 return; 341 return;
342 } 342 }
343 343
344 if (oldPile) { 344 if (oldPile) {
345 item = (CanvasCard *)c; 345 item = (CanvasCard *)c;
346 } else { 346 } else {
347 item = NULL; 347 item = NULL;
348 } 348 }
349 } 349 }
350 alphaCardPile->hide(); 350 alphaCardPile->hide();
351 moving = NULL; 351 moving = NULL;
352 return; 352 return;
353 } 353 }
354 } 354 }
355 355
356 alphaCardPile->animatedMove(); 356 alphaCardPile->animatedMove();
357 } 357 }
358 } 358 }
359 359
360 moved = FALSE; 360 moved = FALSE;
361} 361}
362 362
363 363
364void CanvasCardGame::readPile( Config& cfg, CardPile *pile, QString name, int& highestZ ) 364void CanvasCardGame::readPile( Config& cfg, CardPile *pile, QString name, int& highestZ )
365{ 365{
366 cfg.setGroup( name ); 366 cfg.setGroup( name );
367 int numberOfCards = cfg.readNumEntry("NumberOfCards", 0); 367 int numberOfCards = cfg.readNumEntry("NumberOfCards", 0);
368 Card *card = NULL; 368 Card *card = NULL;
369 369
370 for ( int i = 0; i < numberOfCards; i++ ) { 370 for ( int i = 0; i < numberOfCards; i++ ) {
371 QString cardStr; 371 QString cardStr;
372 cardStr.sprintf( "%i", i ); 372 cardStr.sprintf( "%i", i );
373 int val = cfg.readNumEntry( "Card" + cardStr ); 373 int val = cfg.readNumEntry( "Card" + cardStr );
374 bool facing = cfg.readBoolEntry( "CardFacing" + cardStr ); 374 bool facing = cfg.readBoolEntry( "CardFacing" + cardStr );
375 375
376 card = cards[ val ]; 376 card = cards[ val ];
377 card->setFace(facing); 377 card->setFace(facing);
378 card->setCardPile(pile); // cam: setCardPile muss vor addCardToTop passieren 378 card->setCardPile(pile); // cam: setCardPile has to happen bevor addCardToTop
379 pile->addCardToTop(card); // weil sonst absturz wg cardAddedToTop 379 pile->addCardToTop(card); // due to a empty pointer if you use cardAddedToTop
380 QPoint p = pile->getCardPos( card ); 380 QPoint p = pile->getCardPos( card );
381 card->setPos( p.x(), p.y(), highestZ ); 381 card->setPos( p.x(), p.y(), highestZ );
382 card->showCard(); 382 card->showCard();
383 highestZ++; 383 highestZ++;
384 } 384 }
385} 385}
386 386
387 387
diff --git a/noncore/games/solitaire/chicanecardgame.cpp b/noncore/games/solitaire/chicanecardgame.cpp
index a242419..6729a94 100644
--- a/noncore/games/solitaire/chicanecardgame.cpp
+++ b/noncore/games/solitaire/chicanecardgame.cpp
@@ -1,68 +1,74 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
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** Modified by C.A.Mader 2002 20** created on base of patiencecardgame by cam (C.A.Mader) 2002
21** Rules for this game:
22 **use 2 decks = 104 cards
23 **deal 8 rows with 3 hidden cards and one open card
24** append red to black and vice versa
25 **each card can be layed on a free place
26 **deal 8 cards at once
21** 27**
22**********************************************************************/ 28**********************************************************************/
23#include <qgfx_qws.h> 29#include <qgfx_qws.h>
24#include "chicanecardgame.h" 30#include "chicanecardgame.h"
25 31
26 32
27extern int highestZ; 33extern int highestZ;
28 34
29 35
30 ChicaneCardGame::ChicaneCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent, 2)// Use 2 Decks 36 ChicaneCardGame::ChicaneCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent, 2)// Use 2 Decks
31{ 37{
32 highestZ = 0; 38 highestZ = 0;
33 39
34 for (int i = 0; i < 8; i++) { 40 for (int i = 0; i < 8; i++) {
35 discardPiles[i] = new ChicaneDiscardPile( 27 + i * 26, 10, canvas() ); 41 discardPiles[i] = new ChicaneDiscardPile( 27 + i * 26, 10, canvas() );
36 addCardPile(discardPiles[i]); 42 addCardPile(discardPiles[i]);
37 } 43 }
38 for (int i = 0; i < 8; i++) { 44 for (int i = 0; i < 8; i++) {
39 workingPiles[i] = new ChicaneWorkingPile( 27 + i * 26, 50, canvas() ); 45 workingPiles[i] = new ChicaneWorkingPile( 27 + i * 26, 50, canvas() );
40 addCardPile(workingPiles[i]); 46 addCardPile(workingPiles[i]);
41 } 47 }
42 faceDownDealingPile = new ChicaneFaceDownDeck( 2, 10, canvas() ); 48 faceDownDealingPile = new ChicaneFaceDownDeck( 2, 10, canvas() );
43} 49}
44 50
45 51
46void ChicaneCardGame::deal(void) 52void ChicaneCardGame::deal(void)
47{ 53{
48 highestZ = 1; 54 highestZ = 1;
49 int t = 0; 55 int t = 0;
50 56
51 beginDealing(); 57 beginDealing();
52 58
53 for (int i = 0; i < 8; i++) { 59 for (int i = 0; i < 8; i++) {
54 for (int k = 0; k < 4; k++, t++) { 60 for (int k = 0; k < 4; k++, t++) {
55 Card *card = cards[t]; 61 Card *card = cards[t];
56 workingPiles[i]->addCardToTop(card); 62 workingPiles[i]->addCardToTop(card);
57 card->setCardPile( workingPiles[i] ); 63 card->setCardPile( workingPiles[i] );
58 card->setPos( 0, 0, highestZ ); 64 card->setPos( 0, 0, highestZ );
59 card->setFace(k==3); 65 card->setFace(k==3);
60 card->move( workingPiles[i]->getCardPos( card ) ); 66 card->move( workingPiles[i]->getCardPos( card ) );
61 card->showCard(); 67 card->showCard();
62 highestZ++; 68 highestZ++;
63 } 69 }
64 } 70 }
65 71
66 for ( ; t < getNumberOfCards(); t++) { 72 for ( ; t < getNumberOfCards(); t++) {
67 Card *card = cards[t]; 73 Card *card = cards[t];
68 faceDownDealingPile->addCardToTop(card); 74 faceDownDealingPile->addCardToTop(card);
diff --git a/noncore/games/solitaire/chicanecardgame.h b/noncore/games/solitaire/chicanecardgame.h
index 668f5f4..f6bd08e 100644
--- a/noncore/games/solitaire/chicanecardgame.h
+++ b/noncore/games/solitaire/chicanecardgame.h
@@ -1,159 +1,168 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
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**
20** created on base of patiencecardgame by cam (C.A.Mader) 2002
21** Rules for this game:
22** use 2 decks = 104 cards
23** deal 8 rows with 3 hidden cards and one open card
24** append red to black and vice versa
25** each card can be layed on a free place
26** deal 8 cards at once
27**
19**********************************************************************/ 28**********************************************************************/
20#ifndef CHICANE_CARD_GAME_H 29#ifndef CHICANE_CARD_GAME_H
21#define CHICANE_CARD_GAME_H 30#define CHICANE_CARD_GAME_H
22 31
23 32
24#include "patiencecardgame.h" 33#include "patiencecardgame.h"
25 34
26 35
27class ChicaneFaceDownDeck : public PatienceFaceDownDeck 36class ChicaneFaceDownDeck : public PatienceFaceDownDeck
28{ 37{
29public: 38public:
30 ChicaneFaceDownDeck(int x, int y, QCanvas *canvas) : 39 ChicaneFaceDownDeck(int x, int y, QCanvas *canvas) :
31 PatienceFaceDownDeck(x, y, canvas) { } 40 PatienceFaceDownDeck(x, y, canvas) { }
32 41
33}; 42};
34 43
35 44
36class ChicaneDiscardPile : public PatienceDiscardPile 45class ChicaneDiscardPile : public PatienceDiscardPile
37{ 46{
38public: 47public:
39 ChicaneDiscardPile(int x, int y, QCanvas *canvas) : 48 ChicaneDiscardPile(int x, int y, QCanvas *canvas) :
40 PatienceDiscardPile(x, y, canvas) { } 49 PatienceDiscardPile(x, y, canvas) { }
41 50
42}; 51};
43 52
44 53
45class ChicaneWorkingPile : public PatienceWorkingPile 54class ChicaneWorkingPile : public PatienceWorkingPile
46{ 55{
47public: 56public:
48 ChicaneWorkingPile(int x, int y, QCanvas *canvas) : 57 ChicaneWorkingPile(int x, int y, QCanvas *canvas) :
49 PatienceWorkingPile(x, y, canvas) { } 58 PatienceWorkingPile(x, y, canvas) { }
50 59
51 virtual bool isAllowedOnTop(Card *card) { 60 virtual bool isAllowedOnTop(Card *card) {
52 if ( card->isFacing() && 61 if ( card->isFacing() &&
53 // ( ( ( cardOnTop() == NULL ) && (card->getValue() == king) ) || // diese Zeile sorgt dafür dass nur Kings auf leere Plätze dürfen 62 // ( ( ( cardOnTop() == NULL ) && (card->getValue() == king) ) || // only kings are allowed on empty places
54 ( (cardOnTop() == NULL) || // auf einen Freiplatz darf alles! 63 ( (cardOnTop() == NULL) || // each card can use an empty place
55 ( (cardOnTop() != NULL) && 64 ( (cardOnTop() != NULL) &&
56 ((int)card->getValue() + 1 == (int)cardOnTop()->getValue()) && 65 ((int)card->getValue() + 1 == (int)cardOnTop()->getValue()) &&
57 (card->isRed() != cardOnTop()->isRed()) ) ) ) 66 (card->isRed() != cardOnTop()->isRed()) ) ) )
58 return TRUE; 67 return TRUE;
59 return FALSE; 68 return FALSE;
60 } 69 }
61 virtual bool isAllowedToBeMoved(Card *card) { 70 virtual bool isAllowedToBeMoved(Card *card) {
62 if (!card->isFacing()) return FALSE; 71 if (!card->isFacing()) return FALSE;
63 72
64 int nextExpectedValue = (int)card->getValue(); 73 int nextExpectedValue = (int)card->getValue();
65 bool nextExpectedColor = card->isRed(); 74 bool nextExpectedColor = card->isRed();
66 75
67 while ((card != NULL)) { 76 while ((card != NULL)) {
68 if ( (int)card->getValue() != nextExpectedValue ) 77 if ( (int)card->getValue() != nextExpectedValue )
69 return FALSE; 78 return FALSE;
70 if ( card->isRed() != nextExpectedColor ) 79 if ( card->isRed() != nextExpectedColor )
71 return FALSE; 80 return FALSE;
72 nextExpectedValue--;; 81 nextExpectedValue--;;
73 nextExpectedColor = !nextExpectedColor; 82 nextExpectedColor = !nextExpectedColor;
74 card = cardInfront(card); 83 card = cardInfront(card);
75 } 84 }
76 return TRUE; 85 return TRUE;
77 } 86 }
78 87
79 virtual void cardRemoved(Card *card) { 88 virtual void cardRemoved(Card *card) {
80 Q_UNUSED(card); 89 Q_UNUSED(card);
81 90
82 Card *newTopCard = cardOnTop(); 91 Card *newTopCard = cardOnTop();
83 92
84 if ( !newTopCard ) { 93 if ( !newTopCard ) {
85 top = QPoint( pileX, pileY ); 94 top = QPoint( pileX, pileY );
86 setNextX( pileX ); 95 setNextX( pileX );
87 setNextY( pileY ); 96 setNextY( pileY );
88 return; 97 return;
89 } else { 98 } else {
90 top = getCardPos(NULL); 99 top = getCardPos(NULL);
91 if ( newTopCard->isFacing() == FALSE ) { 100 if ( newTopCard->isFacing() == FALSE ) {
92 int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; 101 int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13;
93 // correct the position taking in to account the card is not 102 // correct the position taking in to account the card is not
94 // yet flipped, but will become flipped 103 // yet flipped, but will become flipped
95 top = QPoint( top.x(), top.y() - 3 ); // Keine Verschiebung! 104 top = QPoint( top.x(), top.y() - 3 ); // no moving to the side
96 newTopCard->flipTo( top.x(), top.y() ); 105 newTopCard->flipTo( top.x(), top.y() );
97 top = QPoint( top.x(), top.y() + offsetDown ); 106 top = QPoint( top.x(), top.y() + offsetDown );
98 } 107 }
99 setNextX( top.x() ); 108 setNextX( top.x() );
100 setNextY( top.y() ); 109 setNextY( top.y() );
101 } 110 }
102 } 111 }
103 virtual QPoint getCardPos(Card *c) { 112 virtual QPoint getCardPos(Card *c) {
104 int x = pileX, y = pileY; 113 int x = pileX, y = pileY;
105 Card *card = cardOnBottom(); 114 Card *card = cardOnBottom();
106 while ((card != c) && (card != NULL)) { 115 while ((card != c) && (card != NULL)) {
107 if (card->isFacing()) { 116 if (card->isFacing()) {
108 int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; 117 int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13;
109 y += offsetDown; 118 y += offsetDown;
110 } else { 119 } else {
111 x += 0; // Keine Verschiebung! 120 x += 0; // no moving to the side
112 y += 3; 121 y += 3;
113 } 122 }
114 card = cardInfront(card); 123 card = cardInfront(card);
115 } 124 }
116 return QPoint( x, y ); 125 return QPoint( x, y );
117 } 126 }
118 127
119 virtual QPoint getHypertheticalNextCardPos(void) { 128 virtual QPoint getHypertheticalNextCardPos(void) {
120// return top; 129// return top;
121 return QPoint( getNextX(), getNextY() ); 130 return QPoint( getNextX(), getNextY() );
122 } 131 }
123 132
124private: 133private:
125 QPoint top; 134 QPoint top;
126 135
127}; 136};
128 137
129 138
130class ChicaneCardGame : public CanvasCardGame 139class ChicaneCardGame : public CanvasCardGame
131{ 140{
132public: 141public:
133 ChicaneCardGame(QCanvas *c, bool snap, QWidget *parent = 0); 142 ChicaneCardGame(QCanvas *c, bool snap, QWidget *parent = 0);
134// virtual ~ChicaneCardGame(); 143// virtual ~ChicaneCardGame();
135 virtual void deal(void); 144 virtual void deal(void);
136 virtual bool haveWeWon() { 145 virtual bool haveWeWon() {
137 return ( discardPiles[0]->kingOnTop() && 146 return ( discardPiles[0]->kingOnTop() &&
138 discardPiles[1]->kingOnTop() && 147 discardPiles[1]->kingOnTop() &&
139 discardPiles[2]->kingOnTop() && 148 discardPiles[2]->kingOnTop() &&
140 discardPiles[3]->kingOnTop() && 149 discardPiles[3]->kingOnTop() &&
141 discardPiles[4]->kingOnTop() && 150 discardPiles[4]->kingOnTop() &&
142 discardPiles[5]->kingOnTop() && 151 discardPiles[5]->kingOnTop() &&
143 discardPiles[6]->kingOnTop() && 152 discardPiles[6]->kingOnTop() &&
144 discardPiles[7]->kingOnTop() );; 153 discardPiles[7]->kingOnTop() );;
145 } 154 }
146 virtual void mousePress(QPoint p); 155 virtual void mousePress(QPoint p);
147 virtual void mouseRelease(QPoint p) { Q_UNUSED(p); } 156 virtual void mouseRelease(QPoint p) { Q_UNUSED(p); }
148// virtual void mouseMove(QPoint p); 157// virtual void mouseMove(QPoint p);
149 virtual bool mousePressCard(Card *card, QPoint p); 158 virtual bool mousePressCard(Card *card, QPoint p);
150 virtual void mouseReleaseCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); } 159 virtual void mouseReleaseCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); }
151// virtual void mouseMoveCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); } 160// virtual void mouseMoveCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); }
152 bool canTurnOverDeck(void) { return (FALSE); } 161 bool canTurnOverDeck(void) { return (FALSE); }
153 void throughDeck(void) { } 162 void throughDeck(void) { }
154 bool snapOn; 163 bool snapOn;
155 void writeConfig( Config& cfg ); 164 void writeConfig( Config& cfg );
156 void readConfig( Config& cfg ); 165 void readConfig( Config& cfg );
157private: 166private:
158 ChicaneWorkingPile *workingPiles[8]; 167 ChicaneWorkingPile *workingPiles[8];
159 ChicaneDiscardPile *discardPiles[8]; 168 ChicaneDiscardPile *discardPiles[8];
diff --git a/noncore/games/solitaire/harpcardgame.cpp b/noncore/games/solitaire/harpcardgame.cpp
index 22715ec..0711622 100644
--- a/noncore/games/solitaire/harpcardgame.cpp
+++ b/noncore/games/solitaire/harpcardgame.cpp
@@ -1,68 +1,76 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
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** Modified by C.A.Mader 2002 20** created on base of patiencecardgame by cam (C.A.Mader) 2002
21** Rules for this game:
22** use 2 decks = 104 cards
23** deal 8 rows with one open card in the first place
24** one hidden and one open in the second place and so on
25** append red to black and vice versa
26** each card can be layed on a free place
27** deal 8 cards at once
28**
21** 29**
22**********************************************************************/ 30**********************************************************************/
23#include <qgfx_qws.h> 31#include <qgfx_qws.h>
24#include "harpcardgame.h" 32#include "harpcardgame.h"
25 33
26 34
27extern int highestZ; 35extern int highestZ;
28 36
29 37
30 HarpCardGame::HarpCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent, 2)// Use 2 Decks 38 HarpCardGame::HarpCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent, 2)// Use 2 Decks
31{ 39{
32 highestZ = 0; 40 highestZ = 0;
33 41
34 for (int i = 0; i < 8; i++) { 42 for (int i = 0; i < 8; i++) {
35 discardPiles[i] = new HarpDiscardPile( 27 + i * 26, 10, canvas() ); 43 discardPiles[i] = new HarpDiscardPile( 27 + i * 26, 10, canvas() );
36 addCardPile(discardPiles[i]); 44 addCardPile(discardPiles[i]);
37 } 45 }
38 for (int i = 0; i < 8; i++) { 46 for (int i = 0; i < 8; i++) {
39 workingPiles[i] = new HarpWorkingPile( 27 + i * 26, 50, canvas() ); 47 workingPiles[i] = new HarpWorkingPile( 27 + i * 26, 50, canvas() );
40 addCardPile(workingPiles[i]); 48 addCardPile(workingPiles[i]);
41 } 49 }
42 faceDownDealingPile = new HarpFaceDownDeck( 2, 10, canvas() ); 50 faceDownDealingPile = new HarpFaceDownDeck( 2, 10, canvas() );
43} 51}
44 52
45 53
46void HarpCardGame::deal(void) 54void HarpCardGame::deal(void)
47{ 55{
48 highestZ = 1; 56 highestZ = 1;
49 int t = 0; 57 int t = 0;
50 58
51 beginDealing(); 59 beginDealing();
52 60
53 for (int i = 0; i < 8; i++) { 61 for (int i = 0; i < 8; i++) {
54 for (int k = 0; k < i+1; k++, t++) { 62 for (int k = 0; k < i+1; k++, t++) {
55 Card *card = cards[t]; 63 Card *card = cards[t];
56 workingPiles[i]->addCardToTop(card); 64 workingPiles[i]->addCardToTop(card);
57 card->setCardPile( workingPiles[i] ); 65 card->setCardPile( workingPiles[i] );
58 card->setPos( 0, 0, highestZ ); 66 card->setPos( 0, 0, highestZ );
59 card->setFace(k==i); 67 card->setFace(k==i);
60 card->move( workingPiles[i]->getCardPos( card ) ); 68 card->move( workingPiles[i]->getCardPos( card ) );
61 card->showCard(); 69 card->showCard();
62 highestZ++; 70 highestZ++;
63 } 71 }
64 } 72 }
65 73
66 for ( ; t < getNumberOfCards(); t++) { 74 for ( ; t < getNumberOfCards(); t++) {
67 Card *card = cards[t]; 75 Card *card = cards[t];
68 faceDownDealingPile->addCardToTop(card); 76 faceDownDealingPile->addCardToTop(card);
diff --git a/noncore/games/solitaire/harpcardgame.h b/noncore/games/solitaire/harpcardgame.h
index d1733fd..18b95e3 100644
--- a/noncore/games/solitaire/harpcardgame.h
+++ b/noncore/games/solitaire/harpcardgame.h
@@ -1,159 +1,169 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
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**
20** created on base of patiencecardgame by cam (C.A.Mader) 2002
21** Rules for this game:
22** use 2 decks = 104 cards
23** deal 8 rows with one open card in the first place
24 **one hidden and one open in the second place and so on
25** append red to black and vice versa
26** each card can be layed on a free place
27** deal 8 cards at once
28**
19**********************************************************************/ 29**********************************************************************/
20#ifndef HARP_CARD_GAME_H 30#ifndef HARP_CARD_GAME_H
21#define HARP_CARD_GAME_H 31#define HARP_CARD_GAME_H
22 32
23 33
24#include "patiencecardgame.h" 34#include "patiencecardgame.h"
25 35
26 36
27class HarpFaceDownDeck : public PatienceFaceDownDeck 37class HarpFaceDownDeck : public PatienceFaceDownDeck
28{ 38{
29public: 39public:
30 HarpFaceDownDeck(int x, int y, QCanvas *canvas) : 40 HarpFaceDownDeck(int x, int y, QCanvas *canvas) :
31 PatienceFaceDownDeck(x, y, canvas) { } 41 PatienceFaceDownDeck(x, y, canvas) { }
32 42
33}; 43};
34 44
35 45
36class HarpDiscardPile : public PatienceDiscardPile 46class HarpDiscardPile : public PatienceDiscardPile
37{ 47{
38public: 48public:
39 HarpDiscardPile(int x, int y, QCanvas *canvas) : 49 HarpDiscardPile(int x, int y, QCanvas *canvas) :
40 PatienceDiscardPile(x, y, canvas) { } 50 PatienceDiscardPile(x, y, canvas) { }
41 51
42}; 52};
43 53
44 54
45class HarpWorkingPile : public PatienceWorkingPile 55class HarpWorkingPile : public PatienceWorkingPile
46{ 56{
47public: 57public:
48 HarpWorkingPile(int x, int y, QCanvas *canvas) : 58 HarpWorkingPile(int x, int y, QCanvas *canvas) :
49 PatienceWorkingPile(x, y, canvas) { } 59 PatienceWorkingPile(x, y, canvas) { }
50 60
51 virtual bool isAllowedOnTop(Card *card) { 61 virtual bool isAllowedOnTop(Card *card) {
52 if ( card->isFacing() && 62 if ( card->isFacing() &&
53 // ( ( ( cardOnTop() == NULL ) && (card->getValue() == king) ) || // diese Zeile sorgt dafür dass nur Kings auf leere Plätze dürfen 63 // ( ( ( cardOnTop() == NULL ) && (card->getValue() == king) ) || // only kings are allowed on empty places
54 ( (cardOnTop() == NULL) || // auf einen Freiplatz darf alles! 64 ( (cardOnTop() == NULL) || // aeach card can use an emply place
55 ( (cardOnTop() != NULL) && 65 ( (cardOnTop() != NULL) &&
56 ((int)card->getValue() + 1 == (int)cardOnTop()->getValue()) && 66 ((int)card->getValue() + 1 == (int)cardOnTop()->getValue()) &&
57 (card->isRed() != cardOnTop()->isRed()) ) ) ) 67 (card->isRed() != cardOnTop()->isRed()) ) ) )
58 return TRUE; 68 return TRUE;
59 return FALSE; 69 return FALSE;
60 } 70 }
61 virtual bool isAllowedToBeMoved(Card *card) { 71 virtual bool isAllowedToBeMoved(Card *card) {
62 if (!card->isFacing()) return FALSE; 72 if (!card->isFacing()) return FALSE;
63 73
64 int nextExpectedValue = (int)card->getValue(); 74 int nextExpectedValue = (int)card->getValue();
65 bool nextExpectedColor = card->isRed(); 75 bool nextExpectedColor = card->isRed();
66 76
67 while ((card != NULL)) { 77 while ((card != NULL)) {
68 if ( (int)card->getValue() != nextExpectedValue ) 78 if ( (int)card->getValue() != nextExpectedValue )
69 return FALSE; 79 return FALSE;
70 if ( card->isRed() != nextExpectedColor ) 80 if ( card->isRed() != nextExpectedColor )
71 return FALSE; 81 return FALSE;
72 nextExpectedValue--;; 82 nextExpectedValue--;;
73 nextExpectedColor = !nextExpectedColor; 83 nextExpectedColor = !nextExpectedColor;
74 card = cardInfront(card); 84 card = cardInfront(card);
75 } 85 }
76 return TRUE; 86 return TRUE;
77 } 87 }
78 88
79 virtual void cardRemoved(Card *card) { 89 virtual void cardRemoved(Card *card) {
80 Q_UNUSED(card); 90 Q_UNUSED(card);
81 91
82 Card *newTopCard = cardOnTop(); 92 Card *newTopCard = cardOnTop();
83 93
84 if ( !newTopCard ) { 94 if ( !newTopCard ) {
85 top = QPoint( pileX, pileY ); 95 top = QPoint( pileX, pileY );
86 setNextX( pileX ); 96 setNextX( pileX );
87 setNextY( pileY ); 97 setNextY( pileY );
88 return; 98 return;
89 } else { 99 } else {
90 top = getCardPos(NULL); 100 top = getCardPos(NULL);
91 if ( newTopCard->isFacing() == FALSE ) { 101 if ( newTopCard->isFacing() == FALSE ) {
92 int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; 102 int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13;
93 // correct the position taking in to account the card is not 103 // correct the position taking in to account the card is not
94 // yet flipped, but will become flipped 104 // yet flipped, but will become flipped
95 top = QPoint( top.x(), top.y() - 3 ); // Keine Verschiebung! 105 top = QPoint( top.x(), top.y() - 3 ); // no moving to the side
96 newTopCard->flipTo( top.x(), top.y() ); 106 newTopCard->flipTo( top.x(), top.y() );
97 top = QPoint( top.x(), top.y() + offsetDown ); 107 top = QPoint( top.x(), top.y() + offsetDown );
98 } 108 }
99 setNextX( top.x() ); 109 setNextX( top.x() );
100 setNextY( top.y() ); 110 setNextY( top.y() );
101 } 111 }
102 } 112 }
103 virtual QPoint getCardPos(Card *c) { 113 virtual QPoint getCardPos(Card *c) {
104 int x = pileX, y = pileY; 114 int x = pileX, y = pileY;
105 Card *card = cardOnBottom(); 115 Card *card = cardOnBottom();
106 while ((card != c) && (card != NULL)) { 116 while ((card != c) && (card != NULL)) {
107 if (card->isFacing()) { 117 if (card->isFacing()) {
108 int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; 118 int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13;
109 y += offsetDown; 119 y += offsetDown;
110 } else { 120 } else {
111 x += 0; // Keine Verschiebung! 121 x += 0; // no moving to the side
112 y += 3; 122 y += 3;
113 } 123 }
114 card = cardInfront(card); 124 card = cardInfront(card);
115 } 125 }
116 return QPoint( x, y ); 126 return QPoint( x, y );
117 } 127 }
118 128
119 virtual QPoint getHypertheticalNextCardPos(void) { 129 virtual QPoint getHypertheticalNextCardPos(void) {
120// return top; 130// return top;
121 return QPoint( getNextX(), getNextY() ); 131 return QPoint( getNextX(), getNextY() );
122 } 132 }
123 133
124private: 134private:
125 QPoint top; 135 QPoint top;
126 136
127}; 137};
128 138
129 139
130class HarpCardGame : public CanvasCardGame 140class HarpCardGame : public CanvasCardGame
131{ 141{
132public: 142public:
133 HarpCardGame(QCanvas *c, bool snap, QWidget *parent = 0); 143 HarpCardGame(QCanvas *c, bool snap, QWidget *parent = 0);
134// virtual ~HarpCardGame(); 144// virtual ~HarpCardGame();
135 virtual void deal(void); 145 virtual void deal(void);
136 virtual bool haveWeWon() { 146 virtual bool haveWeWon() {
137 return ( discardPiles[0]->kingOnTop() && 147 return ( discardPiles[0]->kingOnTop() &&
138 discardPiles[1]->kingOnTop() && 148 discardPiles[1]->kingOnTop() &&
139 discardPiles[2]->kingOnTop() && 149 discardPiles[2]->kingOnTop() &&
140 discardPiles[3]->kingOnTop() && 150 discardPiles[3]->kingOnTop() &&
141 discardPiles[4]->kingOnTop() && 151 discardPiles[4]->kingOnTop() &&
142 discardPiles[5]->kingOnTop() && 152 discardPiles[5]->kingOnTop() &&
143 discardPiles[6]->kingOnTop() && 153 discardPiles[6]->kingOnTop() &&
144 discardPiles[7]->kingOnTop() );; 154 discardPiles[7]->kingOnTop() );;
145 } 155 }
146 virtual void mousePress(QPoint p); 156 virtual void mousePress(QPoint p);
147 virtual void mouseRelease(QPoint p) { Q_UNUSED(p); } 157 virtual void mouseRelease(QPoint p) { Q_UNUSED(p); }
148// virtual void mouseMove(QPoint p); 158// virtual void mouseMove(QPoint p);
149 virtual bool mousePressCard(Card *card, QPoint p); 159 virtual bool mousePressCard(Card *card, QPoint p);
150 virtual void mouseReleaseCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); } 160 virtual void mouseReleaseCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); }
151// virtual void mouseMoveCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); } 161// virtual void mouseMoveCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); }
152 bool canTurnOverDeck(void) { return (FALSE); } 162 bool canTurnOverDeck(void) { return (FALSE); }
153 void throughDeck(void) { } 163 void throughDeck(void) { }
154 bool snapOn; 164 bool snapOn;
155 void writeConfig( Config& cfg ); 165 void writeConfig( Config& cfg );
156 void readConfig( Config& cfg ); 166 void readConfig( Config& cfg );
157private: 167private:
158 HarpWorkingPile *workingPiles[8]; 168 HarpWorkingPile *workingPiles[8];
159 HarpDiscardPile *discardPiles[8]; 169 HarpDiscardPile *discardPiles[8];
diff --git a/noncore/games/solitaire/teeclubcardgame.cpp b/noncore/games/solitaire/teeclubcardgame.cpp
index e15da96..0941e0d 100644
--- a/noncore/games/solitaire/teeclubcardgame.cpp
+++ b/noncore/games/solitaire/teeclubcardgame.cpp
@@ -1,135 +1,143 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
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** Modified by C.A.Mader 2002 20** created on base of patiencecardgame by cam (C.A.Mader) 2002
21** Rules for this game:
22** use 2 decks = 104 cards
23** deal 9 rows with 5 open cards each
24** append one card to each other card which is one step higher
25** move only columns of cards which are equal in suit
26** each card can be layed on a free place
27** deal 1 card at once on the first pile
28**
21** 29**
22**********************************************************************/ 30**********************************************************************/
23#include <qgfx_qws.h> 31#include <qgfx_qws.h>
24#include "teeclubcardgame.h" 32#include "teeclubcardgame.h"
25 33
26 34
27extern int highestZ; 35extern int highestZ;
28 36
29 37
30 TeeclubCardGame::TeeclubCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent, 2)// Use 2 Decks 38 TeeclubCardGame::TeeclubCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent, 2)// Use 2 Decks
31{ 39{
32 highestZ = 0; 40 highestZ = 0;
33 41
34 for (int i = 0; i < 8; i++) { 42 for (int i = 0; i < 8; i++) {
35 discardPiles[i] = new TeeclubDiscardPile( 27 + i * 26, 10, canvas() ); 43 discardPiles[i] = new TeeclubDiscardPile( 27 + i * 26, 10, canvas() );
36 addCardPile(discardPiles[i]); 44 addCardPile(discardPiles[i]);
37 } 45 }
38 for (int i = 0; i < 9; i++) { 46 for (int i = 0; i < 9; i++) {
39 workingPiles[i] = new TeeclubWorkingPile( 2 + i * 26, 50, canvas() ); 47 workingPiles[i] = new TeeclubWorkingPile( 2 + i * 26, 50, canvas() );
40 addCardPile(workingPiles[i]); 48 addCardPile(workingPiles[i]);
41 } 49 }
42 faceDownDealingPile = new TeeclubFaceDownDeck( 2, 10, canvas() ); 50 faceDownDealingPile = new TeeclubFaceDownDeck( 2, 10, canvas() );
43} 51}
44 52
45 53
46void TeeclubCardGame::deal(void) 54void TeeclubCardGame::deal(void)
47{ 55{
48 highestZ = 1; 56 highestZ = 1;
49 int t = 0; 57 int t = 0;
50 58
51 beginDealing(); 59 beginDealing();
52 60
53 for (int i = 0; i < 9; i++) { 61 for (int i = 0; i < 9; i++) {
54 workingPiles[i]->setOffsetDown(13); 62 workingPiles[i]->setOffsetDown(13);
55 workingPiles[i]->beginPileResize(); 63 workingPiles[i]->beginPileResize();
56 for (int k = 0; k < 5; k++, t++) { 64 for (int k = 0; k < 5; k++, t++) {
57 Card *card = cards[t]; 65 Card *card = cards[t];
58 workingPiles[i]->addCardToTop(card); 66 workingPiles[i]->addCardToTop(card);
59 card->setCardPile( workingPiles[i] ); 67 card->setCardPile( workingPiles[i] );
60 card->setPos( 0, 0, highestZ ); 68 card->setPos( 0, 0, highestZ );
61 card->setFace(TRUE); 69 card->setFace(TRUE);
62 card->move( workingPiles[i]->getCardPos( card ) ); 70 card->move( workingPiles[i]->getCardPos( card ) );
63 card->showCard(); 71 card->showCard();
64 highestZ++; 72 highestZ++;
65 } 73 }
66 } 74 }
67 75
68 for ( ; t < getNumberOfCards(); t++) { 76 for ( ; t < getNumberOfCards(); t++) {
69 Card *card = cards[t]; 77 Card *card = cards[t];
70 faceDownDealingPile->addCardToTop(card); 78 faceDownDealingPile->addCardToTop(card);
71 card->setCardPile( faceDownDealingPile ); 79 card->setCardPile( faceDownDealingPile );
72 QPoint p = faceDownDealingPile->getCardPos( card ); 80 QPoint p = faceDownDealingPile->getCardPos( card );
73 card->setPos( p.x(), p.y(), highestZ ); 81 card->setPos( p.x(), p.y(), highestZ );
74 card->showCard(); 82 card->showCard();
75 highestZ++; 83 highestZ++;
76 } 84 }
77 85
78 endDealing(); 86 endDealing();
79} 87}
80 88
81 89
82void TeeclubCardGame::resizePiles() 90void TeeclubCardGame::resizePiles()
83{ 91{
84 beginDealing(); 92 beginDealing();
85 for (int i = 0; i < 9; i++) { 93 for (int i = 0; i < 9; i++) {
86 while ((workingPiles[i]->getCardPos(NULL).y() > 230) && (workingPiles[i]->getOffsetDown()>1)) { 94 while ((workingPiles[i]->getCardPos(NULL).y() > 230) && (workingPiles[i]->getOffsetDown()>1)) {
87 // Resizen des Stapels 95 // resize the pile
88 workingPiles[i]->setOffsetDown(workingPiles[i]->getOffsetDown()-1); 96 workingPiles[i]->setOffsetDown(workingPiles[i]->getOffsetDown()-1);
89 Card *card = workingPiles[i]->cardOnBottom(); 97 Card *card = workingPiles[i]->cardOnBottom();
90 int p=0; 98 int p=0;
91 while (card != NULL) { 99 while (card != NULL) {
92 card->setPos( 0, 0, p++ ); 100 card->setPos( 0, 0, p++ );
93 card->move( workingPiles[i]->getCardPos( card ) ); 101 card->move( workingPiles[i]->getCardPos( card ) );
94 card = workingPiles[i]->cardInfront(card); 102 card = workingPiles[i]->cardInfront(card);
95 } 103 }
96 } 104 }
97 } 105 }
98 endDealing(); 106 endDealing();
99} 107}
100 108
101 109
102void TeeclubCardGame::readConfig( Config& cfg ) 110void TeeclubCardGame::readConfig( Config& cfg )
103{ 111{
104 cfg.setGroup("GameState"); 112 cfg.setGroup("GameState");
105 113
106 // Create Cards, but don't shuffle or deal them yet 114 // Create Cards, but don't shuffle or deal them yet
107 createDeck(); 115 createDeck();
108 116
109 // Move the cards to their piles (deal them to their previous places) 117 // Move the cards to their piles (deal them to their previous places)
110 beginDealing(); 118 beginDealing();
111 119
112 highestZ = 1; 120 highestZ = 1;
113 121
114 for (int i = 0; i < 8; i++) { 122 for (int i = 0; i < 8; i++) {
115 QString pile; 123 QString pile;
116 pile.sprintf( "TeeclubDiscardPile%i", i ); 124 pile.sprintf( "TeeclubDiscardPile%i", i );
117 readPile( cfg, discardPiles[i], pile, highestZ ); 125 readPile( cfg, discardPiles[i], pile, highestZ );
118 } 126 }
119 127
120 for (int i = 0; i < 9; i++) { 128 for (int i = 0; i < 9; i++) {
121 workingPiles[i]->endPileResize(); 129 workingPiles[i]->endPileResize();
122 QString pile; 130 QString pile;
123 pile.sprintf( "TeeclubWorkingPile%i", i ); 131 pile.sprintf( "TeeclubWorkingPile%i", i );
124 readPile( cfg, workingPiles[i], pile, highestZ ); 132 readPile( cfg, workingPiles[i], pile, highestZ );
125 workingPiles[i]->beginPileResize(); 133 workingPiles[i]->beginPileResize();
126 } 134 }
127 135
128 readPile( cfg, faceDownDealingPile, "TeeclubFaceDownDealingPile", highestZ ); 136 readPile( cfg, faceDownDealingPile, "TeeclubFaceDownDealingPile", highestZ );
129 137
130 highestZ++; 138 highestZ++;
131 139
132 endDealing(); 140 endDealing();
133 resizePiles(); 141 resizePiles();
134} 142}
135 143
diff --git a/noncore/games/solitaire/teeclubcardgame.h b/noncore/games/solitaire/teeclubcardgame.h
index 06d49f8..25cfaf9 100644
--- a/noncore/games/solitaire/teeclubcardgame.h
+++ b/noncore/games/solitaire/teeclubcardgame.h
@@ -1,205 +1,216 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
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**
20** created on base of patiencecardgame by cam (C.A.Mader) 2002
21** Rules for this game:
22** use 2 decks = 104 cards
23** deal 9 rows with 5 open cards each
24** append one card to each other card which is one step higher
25 **move only columns of cards which are equal in suit
26** each card can be layed on a free place
27** deal 1 card at once on the first pile
28**
29**
19**********************************************************************/ 30**********************************************************************/
20#ifndef TEECLUB_CARD_GAME_H 31#ifndef TEECLUB_CARD_GAME_H
21#define TEECLUB_CARD_GAME_H 32#define TEECLUB_CARD_GAME_H
22 33
23 34
24#include "patiencecardgame.h" 35#include "patiencecardgame.h"
25 36
26 37
27class TeeclubFaceDownDeck : public PatienceFaceDownDeck 38class TeeclubFaceDownDeck : public PatienceFaceDownDeck
28{ 39{
29public: 40public:
30 TeeclubFaceDownDeck(int x, int y, QCanvas *canvas) : 41 TeeclubFaceDownDeck(int x, int y, QCanvas *canvas) :
31 PatienceFaceDownDeck(x, y, canvas) { } 42 PatienceFaceDownDeck(x, y, canvas) { }
32 43
33}; 44};
34 45
35 46
36class TeeclubDiscardPile : public CardPile, public CanvasRoundRect 47class TeeclubDiscardPile : public CardPile, public CanvasRoundRect
37{ 48{
38public: 49public:
39 TeeclubDiscardPile(int x, int y, QCanvas *canvas) 50 TeeclubDiscardPile(int x, int y, QCanvas *canvas)
40 : CardPile(x, y), CanvasRoundRect(x, y, canvas) { } 51 : CardPile(x, y), CanvasRoundRect(x, y, canvas) { }
41 virtual bool isAllowedOnTop(Card *card) { 52 virtual bool isAllowedOnTop(Card *card) {
42 if ( card->isFacing() && ( card->getCardPile()->cardInfront(card) == NULL ) && 53 if ( card->isFacing() && ( card->getCardPile()->cardInfront(card) == NULL ) &&
43 ( ( ( cardOnTop() == NULL ) && ( card->getValue() == ace ) ) || 54 ( ( ( cardOnTop() == NULL ) && ( card->getValue() == ace ) ) ||
44 ( ( cardOnTop() != NULL ) && 55 ( ( cardOnTop() != NULL ) &&
45 ( (int)card->getValue() == (int)cardOnTop()->getValue() + 1 ) && 56 ( (int)card->getValue() == (int)cardOnTop()->getValue() + 1 ) &&
46 ( card->getSuit() == cardOnTop()->getSuit() ) ) ) ) 57 ( card->getSuit() == cardOnTop()->getSuit() ) ) ) )
47 return TRUE; 58 return TRUE;
48 return FALSE; 59 return FALSE;
49 } 60 }
50 virtual bool isAllowedToBeMoved(Card *card) { 61 virtual bool isAllowedToBeMoved(Card *card) {
51 if (card->isFacing()) return FALSE; 62 if (card->isFacing()) return FALSE;
52 return FALSE; // die Toten ruhn 63 return FALSE; // the deads are sleeping forever
53 } 64 }
54}; 65};
55 66
56 67
57class TeeclubWorkingPile : public PatienceWorkingPile 68class TeeclubWorkingPile : public PatienceWorkingPile
58{ 69{
59public: 70public:
60 TeeclubWorkingPile(int x, int y, QCanvas *canvas) : 71 TeeclubWorkingPile(int x, int y, QCanvas *canvas) :
61 PatienceWorkingPile(x, y, canvas) { } 72 PatienceWorkingPile(x, y, canvas) { }
62 73
63 virtual bool isAllowedOnTop(Card *card) { 74 virtual bool isAllowedOnTop(Card *card) {
64 if ( card->isFacing() && 75 if ( card->isFacing() &&
65 // ( ( ( cardOnTop() == NULL ) && (card->getValue() == king) ) || // diese Zeile sorgt dafür dass nur Kings auf leere Plätze dürfen 76 // ( ( ( cardOnTop() == NULL ) && (card->getValue() == king) ) || // use this if only Kings are allowed on empty places
66 ( (cardOnTop() == NULL) || // auf einen Freiplatz darf alles! 77 ( (cardOnTop() == NULL) || // each card can use an empty place
67 ( (cardOnTop() != NULL) && 78 ( (cardOnTop() != NULL) &&
68 ((int)card->getValue() + 1 == (int)cardOnTop()->getValue()) // bei teeclub sind die farben zum Anlegen egal 79 ((int)card->getValue() + 1 == (int)cardOnTop()->getValue()) // you can append every color on every color
69 ) ) ) 80 ) ) )
70 return TRUE; 81 return TRUE;
71 return FALSE; 82 return FALSE;
72 } 83 }
73 84
74 virtual bool isAllowedToBeMoved(Card *card) { 85 virtual bool isAllowedToBeMoved(Card *card) {
75 if (!card->isFacing()) return FALSE; 86 if (!card->isFacing()) return FALSE;
76 87
77 int nextExpectedValue = (int)card->getValue(); 88 int nextExpectedValue = (int)card->getValue();
78 eSuit nextExpectedSuit = card->getSuit(); 89 eSuit nextExpectedSuit = card->getSuit();
79 90
80 while ((card != NULL)) { 91 while ((card != NULL)) {
81 if ( (int)card->getValue() != nextExpectedValue ) 92 if ( (int)card->getValue() != nextExpectedValue )
82 return FALSE; 93 return FALSE;
83 if ( card->getSuit() != nextExpectedSuit ) 94 if ( card->getSuit() != nextExpectedSuit )
84 return FALSE; 95 return FALSE;
85 nextExpectedValue--;; 96 nextExpectedValue--;;
86 card = cardInfront(card); 97 card = cardInfront(card);
87 } 98 }
88 return TRUE; 99 return TRUE;
89 } 100 }
90 101
91 virtual void cardRemoved(Card *card) { 102 virtual void cardRemoved(Card *card) {
92 Q_UNUSED(card); 103 Q_UNUSED(card);
93 104
94 Card *newTopCard = cardOnTop(); 105 Card *newTopCard = cardOnTop();
95 106
96 if ( !newTopCard ) { 107 if ( !newTopCard ) {
97 top = QPoint( pileX, pileY ); 108 top = QPoint( pileX, pileY );
98 setNextX( pileX ); 109 setNextX( pileX );
99 setNextY( pileY ); 110 setNextY( pileY );
100 setOffsetDown(13); 111 setOffsetDown(13);
101 return; 112 return;
102 } else { 113 } else {
103 top = getCardPos(NULL); 114 top = getCardPos(NULL);
104 if ( newTopCard->isFacing() == FALSE ) { 115 if ( newTopCard->isFacing() == FALSE ) {
105 int offsetDown = newTopCard->getCardPile()->getOffsetDown(); 116 int offsetDown = newTopCard->getCardPile()->getOffsetDown();
106 // correct the position taking in to account the card is not 117 // correct the position taking in to account the card is not
107 // yet flipped, but will become flipped 118 // yet flipped, but will become flipped
108 top = QPoint( top.x(), top.y() - 3 ); // Keine seitliche Verschiebung! 119 top = QPoint( top.x(), top.y() - 3 ); // no moving to the side
109 newTopCard->flipTo( top.x(), top.y() ); 120 newTopCard->flipTo( top.x(), top.y() );
110 top = QPoint( top.x(), top.y() + offsetDown ); 121 top = QPoint( top.x(), top.y() + offsetDown );
111 } 122 }
112 setNextX( top.x() ); 123 setNextX( top.x() );
113 setNextY( top.y() ); 124 setNextY( top.y() );
114 } 125 }
115 126
116 if ((getCardPos(NULL).y() < 230) && (getOffsetDown()<13)) { 127 if ((getCardPos(NULL).y() < 230) && (getOffsetDown()<13)) {
117 // Resizen des Stapels 128 // resize the pile
118 beginDealing(); 129 beginDealing();
119 setOffsetDown(getOffsetDown()+1); 130 setOffsetDown(getOffsetDown()+1);
120 Card *card = cardOnBottom(); 131 Card *card = cardOnBottom();
121 int p=0; 132 int p=0;
122 while (card != NULL) { 133 while (card != NULL) {
123 card->setPos( 0, 0, p++ ); 134 card->setPos( 0, 0, p++ );
124 card->move( getCardPos( card ) ); 135 card->move( getCardPos( card ) );
125 card = cardInfront(card); 136 card = cardInfront(card);
126 } 137 }
127 endDealing(); 138 endDealing();
128 } 139 }
129 } 140 }
130 141
131 virtual QPoint getCardPos(Card *c) { 142 virtual QPoint getCardPos(Card *c) {
132 int x = pileX, y = pileY; 143 int x = pileX, y = pileY;
133 Card *card = cardOnBottom(); 144 Card *card = cardOnBottom();
134 while ((card != c) && (card != NULL)) { 145 while ((card != c) && (card != NULL)) {
135 if (card->isFacing()) { 146 if (card->isFacing()) {
136 int offsetDown = card->getCardPile()->getOffsetDown(); 147 int offsetDown = card->getCardPile()->getOffsetDown();
137 y += offsetDown; 148 y += offsetDown;
138 } else { 149 } else {
139 x += 0; // Keine seitliche Verschiebung! 150 x += 0; // no moving to the side
140 y += 3; 151 y += 3;
141 } 152 }
142 card = cardInfront(card); 153 card = cardInfront(card);
143 } 154 }
144 return QPoint( x, y ); 155 return QPoint( x, y );
145 } 156 }
146 157
147 virtual QPoint getHypertheticalNextCardPos(void) { 158 virtual QPoint getHypertheticalNextCardPos(void) {
148 return QPoint( getNextX(), getNextY() ); 159 return QPoint( getNextX(), getNextY() );
149 } 160 }
150 161
151 virtual void cardAddedToTop(Card *c) { 162 virtual void cardAddedToTop(Card *c) {
152 Q_UNUSED(c); 163 Q_UNUSED(c);
153 setNextX( getCardPos(NULL).x() ); 164 setNextX( getCardPos(NULL).x() );
154 setNextY( getCardPos(NULL).y() ); 165 setNextY( getCardPos(NULL).y() );
155 166
156 while (isPileResize() && (getCardPos(NULL).y() > 230) && (getOffsetDown()>1)) { 167 while (isPileResize() && (getCardPos(NULL).y() > 230) && (getOffsetDown()>1)) {
157 // Resizen des Stapels 168 // resize the pile
158 beginDealing(); 169 beginDealing();
159 setOffsetDown(getOffsetDown()-1); 170 setOffsetDown(getOffsetDown()-1);
160 Card *card = cardOnBottom(); 171 Card *card = cardOnBottom();
161 int p=0; 172 int p=0;
162 while (card != NULL) { 173 while (card != NULL) {
163 card->setPos( 0, 0, p++ ); 174 card->setPos( 0, 0, p++ );
164 card->move( getCardPos( card ) ); 175 card->move( getCardPos( card ) );
165 card = cardInfront(card); 176 card = cardInfront(card);
166 } 177 }
167 endDealing(); 178 endDealing();
168 } 179 }
169 180
170 } 181 }
171 182
172 183
173 184
174 185
175private: 186private:
176 QPoint top; 187 QPoint top;
177 188
178}; 189};
179 190
180 191
181class TeeclubCardGame : public CanvasCardGame 192class TeeclubCardGame : public CanvasCardGame
182{ 193{
183public: 194public:
184 TeeclubCardGame(QCanvas *c, bool snap, QWidget *parent = 0); 195 TeeclubCardGame(QCanvas *c, bool snap, QWidget *parent = 0);
185// virtual ~TeeclubCardGame(); 196// virtual ~TeeclubCardGame();
186 virtual void deal(void); 197 virtual void deal(void);
187 virtual bool haveWeWon() { 198 virtual bool haveWeWon() {
188 return ( discardPiles[0]->kingOnTop() && 199 return ( discardPiles[0]->kingOnTop() &&
189 discardPiles[1]->kingOnTop() && 200 discardPiles[1]->kingOnTop() &&
190 discardPiles[2]->kingOnTop() && 201 discardPiles[2]->kingOnTop() &&
191 discardPiles[3]->kingOnTop() && 202 discardPiles[3]->kingOnTop() &&
192 discardPiles[4]->kingOnTop() && 203 discardPiles[4]->kingOnTop() &&
193 discardPiles[5]->kingOnTop() && 204 discardPiles[5]->kingOnTop() &&
194 discardPiles[6]->kingOnTop() && 205 discardPiles[6]->kingOnTop() &&
195 discardPiles[7]->kingOnTop() );; 206 discardPiles[7]->kingOnTop() );;
196 } 207 }
197 virtual void mousePress(QPoint p); 208 virtual void mousePress(QPoint p);
198 virtual void mouseRelease(QPoint p) { Q_UNUSED(p); } 209 virtual void mouseRelease(QPoint p) { Q_UNUSED(p); }
199// virtual void mouseMove(QPoint p); 210// virtual void mouseMove(QPoint p);
200 virtual bool mousePressCard(Card *card, QPoint p); 211 virtual bool mousePressCard(Card *card, QPoint p);
201 virtual void mouseReleaseCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); } 212 virtual void mouseReleaseCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); }
202// virtual void mouseMoveCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); } 213// virtual void mouseMoveCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); }
203 bool canTurnOverDeck(void) { return (FALSE); } 214 bool canTurnOverDeck(void) { return (FALSE); }
204 void throughDeck(void) { } 215 void throughDeck(void) { }
205 bool snapOn; 216 bool snapOn;