summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/solitaire/canvascardgame.cpp4
-rw-r--r--noncore/games/solitaire/canvascardwindow.cpp28
-rw-r--r--noncore/games/solitaire/canvascardwindow.h1
-rw-r--r--noncore/games/solitaire/cardgamelayout.cpp2
-rw-r--r--noncore/games/solitaire/cardpile.cpp3
-rw-r--r--noncore/games/solitaire/cardpile.h14
-rwxr-xr-xnoncore/games/solitaire/solitaire.pro35
-rw-r--r--noncore/games/solitaire/teeclubcardgame.cpp194
-rw-r--r--noncore/games/solitaire/teeclubcardgame.h217
9 files changed, 476 insertions, 22 deletions
diff --git a/noncore/games/solitaire/canvascardgame.cpp b/noncore/games/solitaire/canvascardgame.cpp
index 357e798..4404b04 100644
--- a/noncore/games/solitaire/canvascardgame.cpp
+++ b/noncore/games/solitaire/canvascardgame.cpp
@@ -366,22 +366,22 @@ void CanvasCardGame::readPile( Config& cfg, CardPile *pile, QString name, int& h
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 pile->addCardToTop(card); 378 card->setCardPile(pile); // cam: setCardPile muss vor addCardToTop passieren
379 card->setCardPile(pile); 379 pile->addCardToTop(card); // weil sonst absturz wg 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/canvascardwindow.cpp b/noncore/games/solitaire/canvascardwindow.cpp
index e1c021e..450b4db 100644
--- a/noncore/games/solitaire/canvascardwindow.cpp
+++ b/noncore/games/solitaire/canvascardwindow.cpp
@@ -14,24 +14,25 @@
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 20
21#include "canvascardwindow.h" 21#include "canvascardwindow.h"
22#include "patiencecardgame.h" 22#include "patiencecardgame.h"
23#include "freecellcardgame.h" 23#include "freecellcardgame.h"
24#include "chicanecardgame.h" 24#include "chicanecardgame.h"
25#include "harpcardgame.h" 25#include "harpcardgame.h"
26#include "teeclubcardgame.h"
26 27
27#include <qpe/resource.h> 28#include <qpe/resource.h>
28 29
29#include <qmainwindow.h> 30#include <qmainwindow.h>
30#include <qpopupmenu.h> 31#include <qpopupmenu.h>
31#include <qstyle.h> 32#include <qstyle.h>
32 33
33 34
34CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) : 35CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) :
35 QMainWindow(parent, name, f), canvas(230, 260), snapOn(TRUE), cardBack(4), gameType(0), 36 QMainWindow(parent, name, f), canvas(230, 260), snapOn(TRUE), cardBack(4), gameType(0),
36 cardGame(NULL) 37 cardGame(NULL)
37{ 38{
@@ -54,48 +55,50 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f)
54 canvas.setAdvancePeriod(30); 55 canvas.setAdvancePeriod(30);
55#endif 56#endif
56 57
57 58
58#ifdef _PATIENCE_USE_ACCELS_ 59#ifdef _PATIENCE_USE_ACCELS_
59 QPEMenuBar* menu = menuBar(); 60 QPEMenuBar* menu = menuBar();
60 61
61 QPopupMenu* file = new QPopupMenu; 62 QPopupMenu* file = new QPopupMenu;
62 file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F); 63 file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F);
63 file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F); 64 file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F);
64 file->insertItem(tr("Chicane"), this, SLOT(initChicane()), CTRL+Key_F); 65 file->insertItem(tr("Chicane"), this, SLOT(initChicane()), CTRL+Key_F);
65 file->insertItem(tr("Harp"), this, SLOT(initHarp()), CTRL+Key_F); 66 file->insertItem(tr("Harp"), this, SLOT(initHarp()), CTRL+Key_F);
67 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()), CTRL+Key_F);
66 menu->insertItem(tr("&Game"), file); 68 menu->insertItem(tr("&Game"), file);
67 69
68 menu->insertSeparator(); 70 menu->insertSeparator();
69 71
70 settings = new QPopupMenu; 72 settings = new QPopupMenu;
71 settings->insertItem(tr("&Change Card Backs"), this, SLOT(changeCardBacks()), Key_F2); 73 settings->insertItem(tr("&Change Card Backs"), this, SLOT(changeCardBacks()), Key_F2);
72 snap_id = settings->insertItem(tr("&Snap To Position"), this, SLOT(snapToggle()), Key_F3); 74 snap_id = settings->insertItem(tr("&Snap To Position"), this, SLOT(snapToggle()), Key_F3);
73 settings->setCheckable(TRUE); 75 settings->setCheckable(TRUE);
74 menu->insertItem(tr("&Settings"),settings); 76 menu->insertItem(tr("&Settings"),settings);
75 77
76 menu->insertSeparator(); 78 menu->insertSeparator();
77 79
78 QPopupMenu* help = new QPopupMenu; 80 QPopupMenu* help = new QPopupMenu;
79 help->insertItem(tr("&About"), this, SLOT(help()), Key_F1); 81 help->insertItem(tr("&About"), this, SLOT(help()), Key_F1);
80 help->setItemChecked(dbf_id, TRUE); 82 help->setItemChecked(dbf_id, TRUE);
81 menu->insertItem(tr("&Help"),help); 83 menu->insertItem(tr("&Help"),help);
82#else 84#else
83 QMenuBar* menu = menuBar(); 85 QMenuBar* menu = menuBar();
84 86
85 QPopupMenu* file = new QPopupMenu; 87 QPopupMenu* file = new QPopupMenu;
86 file->insertItem(tr("Patience"), this, SLOT(initPatience())); 88 file->insertItem(tr("Patience"), this, SLOT(initPatience()));
87 file->insertItem(tr("Freecell"), this, SLOT(initFreecell())); 89 file->insertItem(tr("Freecell"), this, SLOT(initFreecell()));
88 file->insertItem(tr("Chicane"), this, SLOT(initChicane())); 90 file->insertItem(tr("Chicane"), this, SLOT(initChicane()));
89 file->insertItem(tr("Harp"), this, SLOT(initHarp())); 91 file->insertItem(tr("Harp"), this, SLOT(initHarp()));
92 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()));
90 menu->insertItem(tr("Play"), file); 93 menu->insertItem(tr("Play"), file);
91 94
92 menu->insertSeparator(); 95 menu->insertSeparator();
93 96
94 settings = new QPopupMenu; 97 settings = new QPopupMenu;
95 settings->setCheckable(TRUE); 98 settings->setCheckable(TRUE);
96 settings->insertItem(tr("Change Card Backs"), this, SLOT(changeCardBacks())); 99 settings->insertItem(tr("Change Card Backs"), this, SLOT(changeCardBacks()));
97 snap_id = settings->insertItem(tr("Snap To Position"), this, SLOT(snapToggle())); 100 snap_id = settings->insertItem(tr("Snap To Position"), this, SLOT(snapToggle()));
98 QString m; 101 QString m;
99 102
100 drawId = settings->insertItem(tr("Turn One Card"), this, SLOT(drawnToggle())); 103 drawId = settings->insertItem(tr("Turn One Card"), this, SLOT(drawnToggle()));
101 menu->insertItem(tr("Settings"),settings); 104 menu->insertItem(tr("Settings"),settings);
@@ -120,33 +123,38 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f)
120 } else if ( gameType == 1 ) { 123 } else if ( gameType == 1 ) {
121 cardGame = new FreecellCardGame( &canvas, snapOn, this ); 124 cardGame = new FreecellCardGame( &canvas, snapOn, this );
122 setCaption(tr("Freecell")); 125 setCaption(tr("Freecell"));
123 setCentralWidget(cardGame); 126 setCentralWidget(cardGame);
124 //cardGame->newGame(); // Until we know how to handle reading freecell config 127 //cardGame->newGame(); // Until we know how to handle reading freecell config
125 cardGame->readConfig( cfg ); 128 cardGame->readConfig( cfg );
126 setCardBacks(); 129 setCardBacks();
127 } else if ( gameType == 2 ) { 130 } else if ( gameType == 2 ) {
128 cardGame = new ChicaneCardGame( &canvas, snapOn, this ); 131 cardGame = new ChicaneCardGame( &canvas, snapOn, this );
129 cardGame->setNumberToDraw(1); 132 cardGame->setNumberToDraw(1);
130 setCaption(tr("Chicane")); 133 setCaption(tr("Chicane"));
131 setCentralWidget(cardGame); 134 setCentralWidget(cardGame);
132 //cardGame->newGame(); // Until we know how to handle reading freecell config
133 cardGame->readConfig( cfg ); 135 cardGame->readConfig( cfg );
134 setCardBacks(); 136 setCardBacks();
135 } else if ( gameType == 3 ) { 137 } else if ( gameType == 3 ) {
136 cardGame = new HarpCardGame( &canvas, snapOn, this ); 138 cardGame = new HarpCardGame( &canvas, snapOn, this );
137 cardGame->setNumberToDraw(1); 139 cardGame->setNumberToDraw(1);
138 setCaption(tr("Harp")); 140 setCaption(tr("Harp"));
139 setCentralWidget(cardGame); 141 setCentralWidget(cardGame);
140 //cardGame->newGame(); // Until we know how to handle reading freecell config 142 cardGame->readConfig( cfg );
143 setCardBacks();
144 } else if ( gameType == 4 ) {
145 cardGame = new TeeclubCardGame( &canvas, snapOn, this );
146 cardGame->setNumberToDraw(1);
147 setCaption(tr("Teeclub"));
148 setCentralWidget(cardGame);
141 cardGame->readConfig( cfg ); 149 cardGame->readConfig( cfg );
142 setCardBacks(); 150 setCardBacks();
143 } else { 151 } else {
144 // Probably there isn't a config file or it is broken 152 // Probably there isn't a config file or it is broken
145 // Start a new game 153 // Start a new game
146 initPatience(); 154 initPatience();
147 } 155 }
148 156
149 updateDraw(); 157 updateDraw();
150} 158}
151 159
152 160
@@ -225,24 +233,40 @@ void CanvasCardWindow::initHarp()
225 delete cardGame; 233 delete cardGame;
226 } 234 }
227 cardGame = new HarpCardGame( &canvas, snapOn, this ); 235 cardGame = new HarpCardGame( &canvas, snapOn, this );
228 cardGame->setNumberToDraw(1); 236 cardGame->setNumberToDraw(1);
229 gameType = 3; 237 gameType = 3;
230 setCaption(tr("Harp")); 238 setCaption(tr("Harp"));
231 setCentralWidget(cardGame); 239 setCentralWidget(cardGame);
232 cardGame->newGame(); 240 cardGame->newGame();
233 setCardBacks(); 241 setCardBacks();
234} 242}
235 243
236 244
245void CanvasCardWindow::initTeeclub()
246{
247 // Create New Game
248 if ( cardGame ) {
249 delete cardGame;
250 }
251 cardGame = new TeeclubCardGame( &canvas, snapOn, this );
252 cardGame->setNumberToDraw(1);
253 gameType = 4;
254 setCaption(tr("Teeclub"));
255 setCentralWidget(cardGame);
256 cardGame->newGame();
257 setCardBacks();
258}
259
260
237void CanvasCardWindow::snapToggle() 261void CanvasCardWindow::snapToggle()
238{ 262{
239 snapOn = !snapOn; 263 snapOn = !snapOn;
240 settings->setItemChecked(snap_id, snapOn); 264 settings->setItemChecked(snap_id, snapOn);
241 cardGame->toggleSnap(); 265 cardGame->toggleSnap();
242} 266}
243 267
244 268
245void CanvasCardWindow::drawnToggle() 269void CanvasCardWindow::drawnToggle()
246{ 270{
247 cardGame->toggleCardsDrawn(); 271 cardGame->toggleCardsDrawn();
248 updateDraw(); 272 updateDraw();
diff --git a/noncore/games/solitaire/canvascardwindow.h b/noncore/games/solitaire/canvascardwindow.h
index aa76730..eddb184 100644
--- a/noncore/games/solitaire/canvascardwindow.h
+++ b/noncore/games/solitaire/canvascardwindow.h
@@ -38,24 +38,25 @@ public:
38 38
39public slots: 39public slots:
40 void setCardBacks(); 40 void setCardBacks();
41 void changeCardBacks(); 41 void changeCardBacks();
42 void snapToggle(); 42 void snapToggle();
43 void drawnToggle(); 43 void drawnToggle();
44 44
45private slots: 45private slots:
46 void initFreecell(); 46 void initFreecell();
47 void initPatience(); 47 void initPatience();
48 void initChicane(); 48 void initChicane();
49 void initHarp(); 49 void initHarp();
50 void initTeeclub();
50 51
51protected: 52protected:
52 virtual void resizeEvent(QResizeEvent *e); 53 virtual void resizeEvent(QResizeEvent *e);
53 54
54 void updateDraw(); 55 void updateDraw();
55private: 56private:
56 QCanvas canvas; 57 QCanvas canvas;
57 bool snapOn; 58 bool snapOn;
58 bool drawThree; 59 bool drawThree;
59 int drawId; 60 int drawId;
60 int cardBack; 61 int cardBack;
61 int gameType; 62 int gameType;
diff --git a/noncore/games/solitaire/cardgamelayout.cpp b/noncore/games/solitaire/cardgamelayout.cpp
index e21d08a..1ceee8d 100644
--- a/noncore/games/solitaire/cardgamelayout.cpp
+++ b/noncore/games/solitaire/cardgamelayout.cpp
@@ -9,25 +9,25 @@
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#include "cardgamelayout.h" 20#include "cardgamelayout.h"
21#include "card.h" 21
22 22
23CardGameLayout::~CardGameLayout() 23CardGameLayout::~CardGameLayout()
24{ 24{
25 // Should I just do setAutoDelete( TRUE ); ? 25 // Should I just do setAutoDelete( TRUE ); ?
26 for (CardPile *p = first(); p != NULL; p = next()) 26 for (CardPile *p = first(); p != NULL; p = next())
27 delete p; 27 delete p;
28} 28}
29 29
30 30
31CardPile *CardGameLayout::closestPile(int x, int y, int maxDistance) 31CardPile *CardGameLayout::closestPile(int x, int y, int maxDistance)
32{ 32{
33 int closestDistance = maxDistance * maxDistance; 33 int closestDistance = maxDistance * maxDistance;
diff --git a/noncore/games/solitaire/cardpile.cpp b/noncore/games/solitaire/cardpile.cpp
index 3b15e93..aace2e2 100644
--- a/noncore/games/solitaire/cardpile.cpp
+++ b/noncore/games/solitaire/cardpile.cpp
@@ -18,32 +18,33 @@
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "cardpile.h" 21#include "cardpile.h"
22#include "card.h" 22#include "card.h"
23 23
24#include <qpe/config.h> 24#include <qpe/config.h>
25#include <qpoint.h> 25#include <qpoint.h>
26 26
27#include <qlist.h> 27#include <qlist.h>
28 28
29 29
30CardPile::CardPile(int x, int y) : pileX(x), pileY(y), dealing(FALSE) { 30CardPile::CardPile(int x, int y) : pileX(x), pileY(y), dealing(FALSE), PileResize(FALSE) {
31 pileWidth = 0; 31 pileWidth = 0;
32 pileHeight = 0; 32 pileHeight = 0;
33 pileNextX = pileX; 33 pileNextX = pileX;
34 pileNextY = pileY; 34 pileNextY = pileY;
35 pileCenterX = x + pileWidth / 2; 35 pileCenterX = x + pileWidth / 2;
36 pileCenterY = y + pileHeight / 2; 36 pileCenterY = y + pileHeight / 2;
37 pileRadius = (pileWidth > pileHeight) ? pileWidth : pileHeight; 37 pileRadius = (pileWidth > pileHeight) ? pileWidth : pileHeight;
38 pileOffsetDown = 13;
38} 39}
39 40
40 41
41int CardPile::distanceFromPile(int x, int y) { 42int CardPile::distanceFromPile(int x, int y) {
42 return (pileCenterX-x)*(pileCenterX-x)+(pileCenterY-y)*(pileCenterY-y); 43 return (pileCenterX-x)*(pileCenterX-x)+(pileCenterY-y)*(pileCenterY-y);
43} 44}
44 45
45 46
46int CardPile::distanceFromNextPos(int x, int y) { 47int CardPile::distanceFromNextPos(int x, int y) {
47 return (pileNextX-x)*(pileNextX-x)+(pileNextY-y)*(pileNextY-y); 48 return (pileNextX-x)*(pileNextX-x)+(pileNextY-y)*(pileNextY-y);
48} 49}
49 50
diff --git a/noncore/games/solitaire/cardpile.h b/noncore/games/solitaire/cardpile.h
index c515bbc..1eb2499 100644
--- a/noncore/games/solitaire/cardpile.h
+++ b/noncore/games/solitaire/cardpile.h
@@ -42,35 +42,47 @@ class Config;
42class CardPile : public QList<Card> 42class CardPile : public QList<Card>
43{ 43{
44public: 44public:
45 CardPile(int x, int y); 45 CardPile(int x, int y);
46 virtual ~CardPile() { } 46 virtual ~CardPile() { }
47 47
48 int getX() { return pileX; } 48 int getX() { return pileX; }
49 int getY() { return pileY; } 49 int getY() { return pileY; }
50 int getNextX() { return pileNextX; } 50 int getNextX() { return pileNextX; }
51 int getNextY() { return pileNextY; } 51 int getNextY() { return pileNextY; }
52 int getWidth() { return pileWidth; } 52 int getWidth() { return pileWidth; }
53 int getHeight() { return pileHeight; } 53 int getHeight() { return pileHeight; }
54 int getOffsetDown() { return pileOffsetDown; }
55 int getAnzCardsInPile() {
56 int anz=0;
57 Card *card = cardOnBottom();
58 while (card != NULL) { anz++; card = cardInfront(card); }
59 return anz;
60 }
54 61
55 void setX(int x) { pileX = x; } 62 void setX(int x) { pileX = x; }
56 void setY(int y) { pileY = y; } 63 void setY(int y) { pileY = y; }
57 void setNextX(int x) { pileNextX = x; } 64 void setNextX(int x) { pileNextX = x; }
58 void setNextY(int y) { pileNextY = y; } 65 void setNextY(int y) { pileNextY = y; }
59 void setWidth(int width) { pileWidth = width; } 66 void setWidth(int width) { pileWidth = width; }
60 void setHeight(int height) { pileHeight = height; } 67 void setHeight(int height) { pileHeight = height; }
68 void setOffsetDown(int down) { pileOffsetDown = down; }
61 69
62 void beginDealing() { dealing = TRUE; } 70 void beginDealing() { dealing = TRUE; }
63 void endDealing() { dealing = FALSE; } 71 void endDealing() { dealing = FALSE; }
64 bool isDealing() { return dealing; } 72 bool isDealing() { return dealing; }
73
74 void beginPileResize() { PileResize = TRUE; }
75 void endPileResize() { PileResize = FALSE; }
76 bool isPileResize() { return PileResize; }
65 77
66 int distanceFromPile(int x, int y); 78 int distanceFromPile(int x, int y);
67 int distanceFromNextPos(int x, int y); 79 int distanceFromNextPos(int x, int y);
68 80
69 Card *cardOnTop() { return getLast(); } 81 Card *cardOnTop() { return getLast(); }
70 Card *cardOnBottom() { return getFirst(); } 82 Card *cardOnBottom() { return getFirst(); }
71 Card *cardInfront(Card *c); 83 Card *cardInfront(Card *c);
72 bool kingOnTop(); 84 bool kingOnTop();
73 85
74 bool addCardToTop(Card *c); 86 bool addCardToTop(Card *c);
75 bool addCardToBottom(Card *c); 87 bool addCardToBottom(Card *c);
76 bool removeCard(Card *c); 88 bool removeCard(Card *c);
@@ -83,19 +95,21 @@ public:
83 virtual bool isAllowedToBeMoved(Card *) { return FALSE; } 95 virtual bool isAllowedToBeMoved(Card *) { return FALSE; }
84 virtual QPoint getCardPos(Card *) { return QPoint(pileX, pileY); } 96 virtual QPoint getCardPos(Card *) { return QPoint(pileX, pileY); }
85 virtual QPoint getHypertheticalNextCardPos() { return QPoint(pileX, pileY); } 97 virtual QPoint getHypertheticalNextCardPos() { return QPoint(pileX, pileY); }
86 98
87 void writeConfig( Config& cfg, QString name ); 99 void writeConfig( Config& cfg, QString name );
88 100
89protected: 101protected:
90 int pileX, pileY; 102 int pileX, pileY;
91 int pileNextX, pileNextY; 103 int pileNextX, pileNextY;
92 int pileWidth, pileHeight; 104 int pileWidth, pileHeight;
93 int pileCenterX, pileCenterY; 105 int pileCenterX, pileCenterY;
94 int pileRadius; 106 int pileRadius;
107 int pileOffsetDown;
95private: 108private:
96 bool dealing; 109 bool dealing;
110 bool PileResize;
97}; 111};
98 112
99 113
100#endif 114#endif
101 115
diff --git a/noncore/games/solitaire/solitaire.pro b/noncore/games/solitaire/solitaire.pro
index b2ba5aa..d08dab0 100755
--- a/noncore/games/solitaire/solitaire.pro
+++ b/noncore/games/solitaire/solitaire.pro
@@ -1,28 +1,31 @@
1 TEMPLATE= app 1 TEMPLATE= app
2
2 CONFIG += qt warn_on release 3 CONFIG += qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin 4 DESTDIR = $(OPIEDIR)/bin
4 5
5 HEADERS = canvascard.h canvasshapes.h cardgame.h cardgamelayout.h cardpile.h card.h carddeck.h canvascardgame.h freecellcardgame.h chicanecardgame.h harpcardgame.h patiencecardgame.h canvascardwindow.h 6 HEADERS = canvascard.h canvasshapes.h cardgame.h cardgamelayout.h cardpile.h card.h carddeck.h canvascardgame.h freecellcardgame.h chicanecardgame.h harpcardgame.h teeclubcardgame.h patiencecardgame.h canvascardwindow.h
6 7
7 SOURCES = canvascard.cpp canvasshapes.cpp cardgame.cpp cardgamelayout.cpp cardpile.cpp card.cpp carddeck.cpp canvascardgame.cpp freecellcardgame.cpp chicanecardgame.cpp harpcardgame.cpp patiencecardgame.cpp canvascardwindow.cpp main.cpp 8 SOURCES = canvascard.cpp canvasshapes.cpp cardgame.cpp cardgamelayout.cpp cardpile.cpp card.cpp carddeck.cpp canvascardgame.cpp freecellcardgame.cpp chicanecardgame.cpp harpcardgame.cpp teeclubcardgame.cpp patiencecardgame.cpp canvascardwindow.cpp main.cpp
8 9
9 TARGET = patience 10 TARGET = patience
11
10INCLUDEPATH += $(OPIEDIR)/include 12INCLUDEPATH += $(OPIEDIR)/include
11 DEPENDPATH+= $(OPIEDIR)/include 13 DEPENDPATH+= $(OPIEDIR)/include
12LIBS += -lqpe 14LIBS += -lqpe
15
13 REQUIRES= patience 16 REQUIRES= patience
14 17
15TRANSLATIONS = ../../../i18n/de/patience.ts \ 18TRANSLATIONS = ../i18n/de/patience.ts
16 ../../../i18n/en/patience.ts \ 19TRANSLATIONS += ../i18n/es/patience.ts
17 ../../../i18n/es/patience.ts \ 20TRANSLATIONS += ../i18n/pt/patience.ts
18 ../../../i18n/fr/patience.ts \ 21TRANSLATIONS += ../i18n/pt_BR/patience.ts
19 ../../../i18n/hu/patience.ts \ 22TRANSLATIONS += ../i18n/en/patience.ts
20 ../../../i18n/ja/patience.ts \ 23TRANSLATIONS += ../i18n/hu/patience.ts
21 ../../../i18n/ko/patience.ts \ 24TRANSLATIONS += ../i18n/ja/patience.ts
22 ../../../i18n/no/patience.ts \ 25TRANSLATIONS += ../i18n/sl/patience.ts
23 ../../../i18n/pl/patience.ts \ 26TRANSLATIONS += ../i18n/ko/patience.ts
24 ../../../i18n/pt/patience.ts \ 27TRANSLATIONS += ../i18n/pl/patience.ts
25 ../../../i18n/pt_BR/patience.ts \ 28TRANSLATIONS += ../i18n/no/patience.ts
26 ../../../i18n/sl/patience.ts \ 29TRANSLATIONS += ../i18n/fr/patience.ts
27 ../../../i18n/zh_CN/patience.ts \ 30TRANSLATIONS += ../i18n/zh_CN/patience.ts
28 ../../../i18n/zh_TW/patience.ts 31TRANSLATIONS += ../i18n/zh_TW/patience.ts
diff --git a/noncore/games/solitaire/teeclubcardgame.cpp b/noncore/games/solitaire/teeclubcardgame.cpp
new file mode 100644
index 0000000..e15da96
--- a/dev/null
+++ b/noncore/games/solitaire/teeclubcardgame.cpp
@@ -0,0 +1,194 @@
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** Modified by C.A.Mader 2002
21**
22**********************************************************************/
23#include <qgfx_qws.h>
24#include "teeclubcardgame.h"
25
26
27extern int highestZ;
28
29
30 TeeclubCardGame::TeeclubCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent, 2)// Use 2 Decks
31{
32 highestZ = 0;
33
34 for (int i = 0; i < 8; i++) {
35 discardPiles[i] = new TeeclubDiscardPile( 27 + i * 26, 10, canvas() );
36 addCardPile(discardPiles[i]);
37 }
38 for (int i = 0; i < 9; i++) {
39 workingPiles[i] = new TeeclubWorkingPile( 2 + i * 26, 50, canvas() );
40 addCardPile(workingPiles[i]);
41 }
42 faceDownDealingPile = new TeeclubFaceDownDeck( 2, 10, canvas() );
43}
44
45
46void TeeclubCardGame::deal(void)
47{
48 highestZ = 1;
49 int t = 0;
50
51 beginDealing();
52
53 for (int i = 0; i < 9; i++) {
54 workingPiles[i]->setOffsetDown(13);
55 workingPiles[i]->beginPileResize();
56 for (int k = 0; k < 5; k++, t++) {
57 Card *card = cards[t];
58 workingPiles[i]->addCardToTop(card);
59 card->setCardPile( workingPiles[i] );
60 card->setPos( 0, 0, highestZ );
61 card->setFace(TRUE);
62 card->move( workingPiles[i]->getCardPos( card ) );
63 card->showCard();
64 highestZ++;
65 }
66 }
67
68 for ( ; t < getNumberOfCards(); t++) {
69 Card *card = cards[t];
70 faceDownDealingPile->addCardToTop(card);
71 card->setCardPile( faceDownDealingPile );
72 QPoint p = faceDownDealingPile->getCardPos( card );
73 card->setPos( p.x(), p.y(), highestZ );
74 card->showCard();
75 highestZ++;
76 }
77
78 endDealing();
79}
80
81
82void TeeclubCardGame::resizePiles()
83{
84 beginDealing();
85 for (int i = 0; i < 9; i++) {
86 while ((workingPiles[i]->getCardPos(NULL).y() > 230) && (workingPiles[i]->getOffsetDown()>1)) {
87 // Resizen des Stapels
88 workingPiles[i]->setOffsetDown(workingPiles[i]->getOffsetDown()-1);
89 Card *card = workingPiles[i]->cardOnBottom();
90 int p=0;
91 while (card != NULL) {
92 card->setPos( 0, 0, p++ );
93 card->move( workingPiles[i]->getCardPos( card ) );
94 card = workingPiles[i]->cardInfront(card);
95 }
96 }
97 }
98 endDealing();
99}
100
101
102void TeeclubCardGame::readConfig( Config& cfg )
103{
104 cfg.setGroup("GameState");
105
106 // Create Cards, but don't shuffle or deal them yet
107 createDeck();
108
109 // Move the cards to their piles (deal them to their previous places)
110 beginDealing();
111
112 highestZ = 1;
113
114 for (int i = 0; i < 8; i++) {
115 QString pile;
116 pile.sprintf( "TeeclubDiscardPile%i", i );
117 readPile( cfg, discardPiles[i], pile, highestZ );
118 }
119
120 for (int i = 0; i < 9; i++) {
121 workingPiles[i]->endPileResize();
122 QString pile;
123 pile.sprintf( "TeeclubWorkingPile%i", i );
124 readPile( cfg, workingPiles[i], pile, highestZ );
125 workingPiles[i]->beginPileResize();
126 }
127
128 readPile( cfg, faceDownDealingPile, "TeeclubFaceDownDealingPile", highestZ );
129
130 highestZ++;
131
132 endDealing();
133 resizePiles();
134}
135
136
137void TeeclubCardGame::writeConfig( Config& cfg )
138{
139 cfg.setGroup("GameState");
140 for ( int i = 0; i < 8; i++ ) {
141 QString pile;
142 pile.sprintf( "TeeclubDiscardPile%i", i );
143 discardPiles[i]->writeConfig( cfg, pile );
144 }
145 for ( int i = 0; i < 9; i++ ) {
146 QString pile;
147 pile.sprintf( "TeeclubWorkingPile%i", i );
148 workingPiles[i]->writeConfig( cfg, pile );
149 }
150 faceDownDealingPile->writeConfig( cfg, "TeeclubFaceDownDealingPile" );
151}
152
153
154bool TeeclubCardGame::mousePressCard( Card *card, QPoint p )
155{
156 Q_UNUSED(p);
157
158 CanvasCard *item = (CanvasCard *)card;
159 if (item->isFacing() != TRUE) {
160 // From facedown stack
161 if ((item->x() == 2) && ((int)item->y() == 10)) { // Deal 1 card
162 // Move 8 cards, one to each workingPile
163 beginDealing();
164 CanvasCard *card = (CanvasCard *)faceDownDealingPile->cardOnTop();
165 card->setZ(highestZ);
166 highestZ++;
167 faceDownDealingPile->removeCard(card);
168 workingPiles[0]->addCardToTop(card);
169 card->setCardPile( workingPiles[0] );
170 card->setFace(FALSE);
171 QPoint p = workingPiles[0]->getCardPos(card);
172 card->flipTo( p.x(), p.y() );
173 endDealing();
174 }
175 moving = NULL;
176 moved = FALSE;
177
178 return TRUE;
179 } else if ( !card->getCardPile()->isAllowedToBeMoved(card) ) {// Don't allow unclean columns to be moved
180 moving = NULL;
181 return TRUE;
182 }
183
184 return FALSE;
185}
186
187
188
189void TeeclubCardGame::mousePress(QPoint p)
190{
191 Q_UNUSED(p);
192}
193
194
diff --git a/noncore/games/solitaire/teeclubcardgame.h b/noncore/games/solitaire/teeclubcardgame.h
new file mode 100644
index 0000000..06d49f8
--- a/dev/null
+++ b/noncore/games/solitaire/teeclubcardgame.h
@@ -0,0 +1,217 @@
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 TEECLUB_CARD_GAME_H
21#define TEECLUB_CARD_GAME_H
22
23
24#include "patiencecardgame.h"
25
26
27class TeeclubFaceDownDeck : public PatienceFaceDownDeck
28{
29public:
30 TeeclubFaceDownDeck(int x, int y, QCanvas *canvas) :
31 PatienceFaceDownDeck(x, y, canvas) { }
32
33};
34
35
36class TeeclubDiscardPile : public CardPile, public CanvasRoundRect
37{
38public:
39 TeeclubDiscardPile(int x, int y, QCanvas *canvas)
40 : CardPile(x, y), CanvasRoundRect(x, y, canvas) { }
41 virtual bool isAllowedOnTop(Card *card) {
42 if ( card->isFacing() && ( card->getCardPile()->cardInfront(card) == NULL ) &&
43 ( ( ( cardOnTop() == NULL ) && ( card->getValue() == ace ) ) ||
44 ( ( cardOnTop() != NULL ) &&
45 ( (int)card->getValue() == (int)cardOnTop()->getValue() + 1 ) &&
46 ( card->getSuit() == cardOnTop()->getSuit() ) ) ) )
47 return TRUE;
48 return FALSE;
49 }
50 virtual bool isAllowedToBeMoved(Card *card) {
51 if (card->isFacing()) return FALSE;
52 return FALSE; // die Toten ruhn
53 }
54};
55
56
57class TeeclubWorkingPile : public PatienceWorkingPile
58{
59public:
60 TeeclubWorkingPile(int x, int y, QCanvas *canvas) :
61 PatienceWorkingPile(x, y, canvas) { }
62
63 virtual bool isAllowedOnTop(Card *card) {
64 if ( card->isFacing() &&
65 // ( ( ( cardOnTop() == NULL ) && (card->getValue() == king) ) || // diese Zeile sorgt dafür dass nur Kings auf leere Plätze dürfen
66 ( (cardOnTop() == NULL) || // auf einen Freiplatz darf alles!
67 ( (cardOnTop() != NULL) &&
68 ((int)card->getValue() + 1 == (int)cardOnTop()->getValue()) // bei teeclub sind die farben zum Anlegen egal
69 ) ) )
70 return TRUE;
71 return FALSE;
72 }
73
74 virtual bool isAllowedToBeMoved(Card *card) {
75 if (!card->isFacing()) return FALSE;
76
77 int nextExpectedValue = (int)card->getValue();
78 eSuit nextExpectedSuit = card->getSuit();
79
80 while ((card != NULL)) {
81 if ( (int)card->getValue() != nextExpectedValue )
82 return FALSE;
83 if ( card->getSuit() != nextExpectedSuit )
84 return FALSE;
85 nextExpectedValue--;;
86 card = cardInfront(card);
87 }
88 return TRUE;
89 }
90
91 virtual void cardRemoved(Card *card) {
92 Q_UNUSED(card);
93
94 Card *newTopCard = cardOnTop();
95
96 if ( !newTopCard ) {
97 top = QPoint( pileX, pileY );
98 setNextX( pileX );
99 setNextY( pileY );
100 setOffsetDown(13);
101 return;
102 } else {
103 top = getCardPos(NULL);
104 if ( newTopCard->isFacing() == FALSE ) {
105 int offsetDown = newTopCard->getCardPile()->getOffsetDown();
106 // correct the position taking in to account the card is not
107 // yet flipped, but will become flipped
108 top = QPoint( top.x(), top.y() - 3 ); // Keine seitliche Verschiebung!
109 newTopCard->flipTo( top.x(), top.y() );
110 top = QPoint( top.x(), top.y() + offsetDown );
111 }
112 setNextX( top.x() );
113 setNextY( top.y() );
114 }
115
116 if ((getCardPos(NULL).y() < 230) && (getOffsetDown()<13)) {
117 // Resizen des Stapels
118 beginDealing();
119 setOffsetDown(getOffsetDown()+1);
120 Card *card = cardOnBottom();
121 int p=0;
122 while (card != NULL) {
123 card->setPos( 0, 0, p++ );
124 card->move( getCardPos( card ) );
125 card = cardInfront(card);
126 }
127 endDealing();
128 }
129 }
130
131 virtual QPoint getCardPos(Card *c) {
132 int x = pileX, y = pileY;
133 Card *card = cardOnBottom();
134 while ((card != c) && (card != NULL)) {
135 if (card->isFacing()) {
136 int offsetDown = card->getCardPile()->getOffsetDown();
137 y += offsetDown;
138 } else {
139 x += 0; // Keine seitliche Verschiebung!
140 y += 3;
141 }
142 card = cardInfront(card);
143 }
144 return QPoint( x, y );
145 }
146
147 virtual QPoint getHypertheticalNextCardPos(void) {
148 return QPoint( getNextX(), getNextY() );
149 }
150
151 virtual void cardAddedToTop(Card *c) {
152 Q_UNUSED(c);
153 setNextX( getCardPos(NULL).x() );
154 setNextY( getCardPos(NULL).y() );
155
156 while (isPileResize() && (getCardPos(NULL).y() > 230) && (getOffsetDown()>1)) {
157 // Resizen des Stapels
158 beginDealing();
159 setOffsetDown(getOffsetDown()-1);
160 Card *card = cardOnBottom();
161 int p=0;
162 while (card != NULL) {
163 card->setPos( 0, 0, p++ );
164 card->move( getCardPos( card ) );
165 card = cardInfront(card);
166 }
167 endDealing();
168 }
169
170 }
171
172
173
174
175private:
176 QPoint top;
177
178};
179
180
181class TeeclubCardGame : public CanvasCardGame
182{
183public:
184 TeeclubCardGame(QCanvas *c, bool snap, QWidget *parent = 0);
185// virtual ~TeeclubCardGame();
186 virtual void deal(void);
187 virtual bool haveWeWon() {
188 return ( discardPiles[0]->kingOnTop() &&
189 discardPiles[1]->kingOnTop() &&
190 discardPiles[2]->kingOnTop() &&
191 discardPiles[3]->kingOnTop() &&
192 discardPiles[4]->kingOnTop() &&
193 discardPiles[5]->kingOnTop() &&
194 discardPiles[6]->kingOnTop() &&
195 discardPiles[7]->kingOnTop() );;
196 }
197 virtual void mousePress(QPoint p);
198 virtual void mouseRelease(QPoint p) { Q_UNUSED(p); }
199// virtual void mouseMove(QPoint p);
200 virtual bool mousePressCard(Card *card, QPoint p);
201 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); }
203 bool canTurnOverDeck(void) { return (FALSE); }
204 void throughDeck(void) { }
205 bool snapOn;
206 void writeConfig( Config& cfg );
207 void readConfig( Config& cfg );
208 void resizePiles();
209private:
210 TeeclubWorkingPile *workingPiles[9];
211 TeeclubDiscardPile *discardPiles[8];
212 TeeclubFaceDownDeck *faceDownDealingPile;
213};
214
215
216#endif
217