-rw-r--r-- | noncore/games/solitaire/canvascardgame.cpp | 4 | ||||
-rw-r--r-- | noncore/games/solitaire/canvascardwindow.cpp | 28 | ||||
-rw-r--r-- | noncore/games/solitaire/canvascardwindow.h | 1 | ||||
-rw-r--r-- | noncore/games/solitaire/cardgamelayout.cpp | 2 | ||||
-rw-r--r-- | noncore/games/solitaire/cardpile.cpp | 3 | ||||
-rw-r--r-- | noncore/games/solitaire/cardpile.h | 14 | ||||
-rwxr-xr-x | noncore/games/solitaire/solitaire.pro | 35 | ||||
-rw-r--r-- | noncore/games/solitaire/teeclubcardgame.cpp | 194 | ||||
-rw-r--r-- | noncore/games/solitaire/teeclubcardgame.h | 217 |
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 | |||
@@ -377,4 +377,4 @@ void CanvasCardGame::readPile( Config& cfg, CardPile *pile, QString name, int& h | |||
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 ); |
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 | |||
@@ -25,2 +25,3 @@ | |||
25 | #include "harpcardgame.h" | 25 | #include "harpcardgame.h" |
26 | #include "teeclubcardgame.h" | ||
26 | 27 | ||
@@ -65,2 +66,3 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags 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); |
@@ -89,2 +91,3 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) | |||
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); |
@@ -131,3 +134,2 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) | |||
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 ); |
@@ -139,3 +141,9 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) | |||
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 ); |
@@ -236,2 +244,18 @@ void CanvasCardWindow::initHarp() | |||
236 | 244 | ||
245 | void 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 | |||
237 | void CanvasCardWindow::snapToggle() | 261 | void CanvasCardWindow::snapToggle() |
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 | |||
@@ -49,2 +49,3 @@ private slots: | |||
49 | void initHarp(); | 49 | void initHarp(); |
50 | void initTeeclub(); | ||
50 | 51 | ||
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 | |||
@@ -20,3 +20,3 @@ | |||
20 | #include "cardgamelayout.h" | 20 | #include "cardgamelayout.h" |
21 | #include "card.h" | 21 | |
22 | 22 | ||
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 | |||
@@ -29,3 +29,3 @@ | |||
29 | 29 | ||
30 | CardPile::CardPile(int x, int y) : pileX(x), pileY(y), dealing(FALSE) { | 30 | CardPile::CardPile(int x, int y) : pileX(x), pileY(y), dealing(FALSE), PileResize(FALSE) { |
31 | pileWidth = 0; | 31 | pileWidth = 0; |
@@ -37,2 +37,3 @@ CardPile::CardPile(int x, int y) : pileX(x), pileY(y), dealing(FALSE) { | |||
37 | pileRadius = (pileWidth > pileHeight) ? pileWidth : pileHeight; | 37 | pileRadius = (pileWidth > pileHeight) ? pileWidth : pileHeight; |
38 | pileOffsetDown = 13; | ||
38 | } | 39 | } |
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 | |||
@@ -53,2 +53,9 @@ public: | |||
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 | ||
@@ -60,2 +67,3 @@ public: | |||
60 | void setHeight(int height) { pileHeight = height; } | 67 | void setHeight(int height) { pileHeight = height; } |
68 | void setOffsetDown(int down) { pileOffsetDown = down; } | ||
61 | 69 | ||
@@ -64,2 +72,6 @@ public: | |||
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 | ||
@@ -94,4 +106,6 @@ protected: | |||
94 | int pileRadius; | 106 | int pileRadius; |
107 | int pileOffsetDown; | ||
95 | private: | 108 | private: |
96 | bool dealing; | 109 | bool dealing; |
110 | bool PileResize; | ||
97 | }; | 111 | }; |
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,2 +1,3 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | |||
2 | CONFIG += qt warn_on release | 3 | CONFIG += qt warn_on release |
@@ -4,7 +5,8 @@ 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 | |||
10 | INCLUDEPATH += $(OPIEDIR)/include | 12 | INCLUDEPATH += $(OPIEDIR)/include |
@@ -12,17 +14,18 @@ DEPENDPATH += $(OPIEDIR)/include | |||
12 | LIBS += -lqpe | 14 | LIBS += -lqpe |
15 | |||
13 | REQUIRES= patience | 16 | REQUIRES= patience |
14 | 17 | ||
15 | TRANSLATIONS = ../../../i18n/de/patience.ts \ | 18 | TRANSLATIONS = ../i18n/de/patience.ts |
16 | ../../../i18n/en/patience.ts \ | 19 | TRANSLATIONS += ../i18n/es/patience.ts |
17 | ../../../i18n/es/patience.ts \ | 20 | TRANSLATIONS += ../i18n/pt/patience.ts |
18 | ../../../i18n/fr/patience.ts \ | 21 | TRANSLATIONS += ../i18n/pt_BR/patience.ts |
19 | ../../../i18n/hu/patience.ts \ | 22 | TRANSLATIONS += ../i18n/en/patience.ts |
20 | ../../../i18n/ja/patience.ts \ | 23 | TRANSLATIONS += ../i18n/hu/patience.ts |
21 | ../../../i18n/ko/patience.ts \ | 24 | TRANSLATIONS += ../i18n/ja/patience.ts |
22 | ../../../i18n/no/patience.ts \ | 25 | TRANSLATIONS += ../i18n/sl/patience.ts |
23 | ../../../i18n/pl/patience.ts \ | 26 | TRANSLATIONS += ../i18n/ko/patience.ts |
24 | ../../../i18n/pt/patience.ts \ | 27 | TRANSLATIONS += ../i18n/pl/patience.ts |
25 | ../../../i18n/pt_BR/patience.ts \ | 28 | TRANSLATIONS += ../i18n/no/patience.ts |
26 | ../../../i18n/sl/patience.ts \ | 29 | TRANSLATIONS += ../i18n/fr/patience.ts |
27 | ../../../i18n/zh_CN/patience.ts \ | 30 | TRANSLATIONS += ../i18n/zh_CN/patience.ts |
28 | ../../../i18n/zh_TW/patience.ts | 31 | TRANSLATIONS += ../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 | |||
27 | extern 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 | |||
46 | void 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 | |||
82 | void 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 | |||
102 | void 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 | |||
137 | void 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 | |||
154 | bool 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 | |||
189 | void 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 | |||
27 | class TeeclubFaceDownDeck : public PatienceFaceDownDeck | ||
28 | { | ||
29 | public: | ||
30 | TeeclubFaceDownDeck(int x, int y, QCanvas *canvas) : | ||
31 | PatienceFaceDownDeck(x, y, canvas) { } | ||
32 | |||
33 | }; | ||
34 | |||
35 | |||
36 | class TeeclubDiscardPile : public CardPile, public CanvasRoundRect | ||
37 | { | ||
38 | public: | ||
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 | |||
57 | class TeeclubWorkingPile : public PatienceWorkingPile | ||
58 | { | ||
59 | public: | ||
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 | |||
175 | private: | ||
176 | QPoint top; | ||
177 | |||
178 | }; | ||
179 | |||
180 | |||
181 | class TeeclubCardGame : public CanvasCardGame | ||
182 | { | ||
183 | public: | ||
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(); | ||
209 | private: | ||
210 | TeeclubWorkingPile *workingPiles[9]; | ||
211 | TeeclubDiscardPile *discardPiles[8]; | ||
212 | TeeclubFaceDownDeck *faceDownDealingPile; | ||
213 | }; | ||
214 | |||
215 | |||
216 | #endif | ||
217 | |||