author | tille <tille> | 2002-06-28 14:56:10 (UTC) |
---|---|---|
committer | tille <tille> | 2002-06-28 14:56:10 (UTC) |
commit | ab413257c3a23f535e99f8f61468382c73bc4adb (patch) (unidiff) | |
tree | 63834da1738157e52b67550d4e71058c6710f1ff | |
parent | d4626cc76127b7022c8555ea11afbb289714c851 (diff) | |
download | opie-ab413257c3a23f535e99f8f61468382c73bc4adb.zip opie-ab413257c3a23f535e99f8f61468382c73bc4adb.tar.gz opie-ab413257c3a23f535e99f8f61468382c73bc4adb.tar.bz2 |
cmader <chris@mediakreativwerk.de> impl. 2 new games
-rw-r--r-- | noncore/games/solitaire/canvascardgame.cpp | 4 | ||||
-rw-r--r-- | noncore/games/solitaire/canvascardgame.h | 3 | ||||
-rw-r--r-- | noncore/games/solitaire/canvascardwindow.cpp | 53 | ||||
-rw-r--r-- | noncore/games/solitaire/canvascardwindow.h | 2 | ||||
-rw-r--r-- | noncore/games/solitaire/card.h | 4 | ||||
-rw-r--r-- | noncore/games/solitaire/carddeck.cpp | 22 | ||||
-rw-r--r-- | noncore/games/solitaire/carddeck.h | 4 | ||||
-rw-r--r-- | noncore/games/solitaire/cardgame.h | 2 | ||||
-rw-r--r-- | noncore/games/solitaire/cardpile.cpp | 2 | ||||
-rw-r--r-- | noncore/games/solitaire/chicanecardgame.cpp | 171 | ||||
-rw-r--r-- | noncore/games/solitaire/chicanecardgame.h | 165 | ||||
-rw-r--r-- | noncore/games/solitaire/harpcardgame.cpp | 171 | ||||
-rw-r--r-- | noncore/games/solitaire/harpcardgame.h | 165 | ||||
-rw-r--r-- | noncore/games/solitaire/patiencecardgame.cpp | 6 | ||||
-rwxr-xr-x | noncore/games/solitaire/solitaire.pro | 7 |
15 files changed, 764 insertions, 17 deletions
diff --git a/noncore/games/solitaire/canvascardgame.cpp b/noncore/games/solitaire/canvascardgame.cpp index ef35287..357e798 100644 --- a/noncore/games/solitaire/canvascardgame.cpp +++ b/noncore/games/solitaire/canvascardgame.cpp | |||
@@ -366,12 +366,14 @@ 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 | for ( int i = 0; i < numberOfCards; i++ ) { | 370 | for ( int i = 0; i < numberOfCards; i++ ) { |
370 | QString cardStr; | 371 | QString cardStr; |
371 | cardStr.sprintf( "%i", i ); | 372 | cardStr.sprintf( "%i", i ); |
372 | int val = cfg.readNumEntry( "Card" + cardStr ); | 373 | int val = cfg.readNumEntry( "Card" + cardStr ); |
373 | bool facing = cfg.readBoolEntry( "CardFacing" + cardStr ); | 374 | bool facing = cfg.readBoolEntry( "CardFacing" + cardStr ); |
374 | card = cards[ val ]; | 375 | |
376 | card = cards[ val ]; | ||
375 | card->setFace(facing); | 377 | card->setFace(facing); |
376 | pile->addCardToTop(card); | 378 | pile->addCardToTop(card); |
377 | card->setCardPile(pile); | 379 | card->setCardPile(pile); |
diff --git a/noncore/games/solitaire/canvascardgame.h b/noncore/games/solitaire/canvascardgame.h index 4d32014..0dfb85e 100644 --- a/noncore/games/solitaire/canvascardgame.h +++ b/noncore/games/solitaire/canvascardgame.h | |||
@@ -41,8 +41,9 @@ class CanvasCardPile; | |||
41 | class CanvasCardGame : public QCanvasView, public CardGame | 41 | class CanvasCardGame : public QCanvasView, public CardGame |
42 | { | 42 | { |
43 | public: | 43 | public: |
44 | CanvasCardGame(QCanvas &c, bool snap, QWidget *parent = 0, const char *name = 0, WFlags f = 0) : | 44 | CanvasCardGame(QCanvas &c, bool snap, QWidget *parent = 0, int numOfDecks = 1, const char *name = 0, WFlags f = 0) : |
45 | QCanvasView( &c, parent, name, f ), | 45 | QCanvasView( &c, parent, name, f ), |
46 | CardGame(0,numOfDecks), | ||
46 | moved(FALSE), | 47 | moved(FALSE), |
47 | moving(NULL), | 48 | moving(NULL), |
48 | alphaCardPile( NULL ), | 49 | alphaCardPile( NULL ), |
diff --git a/noncore/games/solitaire/canvascardwindow.cpp b/noncore/games/solitaire/canvascardwindow.cpp index 4c365a5..e1c021e 100644 --- a/noncore/games/solitaire/canvascardwindow.cpp +++ b/noncore/games/solitaire/canvascardwindow.cpp | |||
@@ -21,6 +21,8 @@ | |||
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" | ||
25 | #include "harpcardgame.h" | ||
24 | 26 | ||
25 | #include <qpe/resource.h> | 27 | #include <qpe/resource.h> |
26 | 28 | ||
@@ -59,6 +61,8 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) | |||
59 | QPopupMenu* file = new QPopupMenu; | 61 | QPopupMenu* file = new QPopupMenu; |
60 | file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F); | 62 | file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F); |
61 | file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F); | 63 | 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("Harp"), this, SLOT(initHarp()), CTRL+Key_F); | ||
62 | menu->insertItem(tr("&Game"), file); | 66 | menu->insertItem(tr("&Game"), file); |
63 | 67 | ||
64 | menu->insertSeparator(); | 68 | menu->insertSeparator(); |
@@ -81,6 +85,8 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) | |||
81 | QPopupMenu* file = new QPopupMenu; | 85 | QPopupMenu* file = new QPopupMenu; |
82 | file->insertItem(tr("Patience"), this, SLOT(initPatience())); | 86 | file->insertItem(tr("Patience"), this, SLOT(initPatience())); |
83 | file->insertItem(tr("Freecell"), this, SLOT(initFreecell())); | 87 | file->insertItem(tr("Freecell"), this, SLOT(initFreecell())); |
88 | file->insertItem(tr("Chicane"), this, SLOT(initChicane())); | ||
89 | file->insertItem(tr("Harp"), this, SLOT(initHarp())); | ||
84 | menu->insertItem(tr("Play"), file); | 90 | menu->insertItem(tr("Play"), file); |
85 | 91 | ||
86 | menu->insertSeparator(); | 92 | menu->insertSeparator(); |
@@ -118,6 +124,22 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) | |||
118 | //cardGame->newGame(); // Until we know how to handle reading freecell config | 124 | //cardGame->newGame(); // Until we know how to handle reading freecell config |
119 | cardGame->readConfig( cfg ); | 125 | cardGame->readConfig( cfg ); |
120 | setCardBacks(); | 126 | setCardBacks(); |
127 | } else if ( gameType == 2 ) { | ||
128 | cardGame = new ChicaneCardGame( &canvas, snapOn, this ); | ||
129 | cardGame->setNumberToDraw(1); | ||
130 | setCaption(tr("Chicane")); | ||
131 | setCentralWidget(cardGame); | ||
132 | //cardGame->newGame(); // Until we know how to handle reading freecell config | ||
133 | cardGame->readConfig( cfg ); | ||
134 | setCardBacks(); | ||
135 | } else if ( gameType == 3 ) { | ||
136 | cardGame = new HarpCardGame( &canvas, snapOn, this ); | ||
137 | cardGame->setNumberToDraw(1); | ||
138 | setCaption(tr("Harp")); | ||
139 | setCentralWidget(cardGame); | ||
140 | //cardGame->newGame(); // Until we know how to handle reading freecell config | ||
141 | cardGame->readConfig( cfg ); | ||
142 | setCardBacks(); | ||
121 | } else { | 143 | } else { |
122 | // Probably there isn't a config file or it is broken | 144 | // Probably there isn't a config file or it is broken |
123 | // Start a new game | 145 | // Start a new game |
@@ -181,6 +203,37 @@ void CanvasCardWindow::initFreecell() | |||
181 | } | 203 | } |
182 | 204 | ||
183 | 205 | ||
206 | void CanvasCardWindow::initChicane() | ||
207 | { | ||
208 | // Create New Game | ||
209 | if ( cardGame ) { | ||
210 | delete cardGame; | ||
211 | } | ||
212 | cardGame = new ChicaneCardGame( &canvas, snapOn, this ); | ||
213 | cardGame->setNumberToDraw(1); | ||
214 | gameType = 2; | ||
215 | setCaption(tr("Chicane")); | ||
216 | setCentralWidget(cardGame); | ||
217 | cardGame->newGame(); | ||
218 | setCardBacks(); | ||
219 | } | ||
220 | |||
221 | void CanvasCardWindow::initHarp() | ||
222 | { | ||
223 | // Create New Game | ||
224 | if ( cardGame ) { | ||
225 | delete cardGame; | ||
226 | } | ||
227 | cardGame = new HarpCardGame( &canvas, snapOn, this ); | ||
228 | cardGame->setNumberToDraw(1); | ||
229 | gameType = 3; | ||
230 | setCaption(tr("Harp")); | ||
231 | setCentralWidget(cardGame); | ||
232 | cardGame->newGame(); | ||
233 | setCardBacks(); | ||
234 | } | ||
235 | |||
236 | |||
184 | void CanvasCardWindow::snapToggle() | 237 | void CanvasCardWindow::snapToggle() |
185 | { | 238 | { |
186 | snapOn = !snapOn; | 239 | snapOn = !snapOn; |
diff --git a/noncore/games/solitaire/canvascardwindow.h b/noncore/games/solitaire/canvascardwindow.h index b75d40a..aa76730 100644 --- a/noncore/games/solitaire/canvascardwindow.h +++ b/noncore/games/solitaire/canvascardwindow.h | |||
@@ -45,6 +45,8 @@ public slots: | |||
45 | private slots: | 45 | private slots: |
46 | void initFreecell(); | 46 | void initFreecell(); |
47 | void initPatience(); | 47 | void initPatience(); |
48 | void initChicane(); | ||
49 | void initHarp(); | ||
48 | 50 | ||
49 | protected: | 51 | protected: |
50 | virtual void resizeEvent(QResizeEvent *e); | 52 | virtual void resizeEvent(QResizeEvent *e); |
diff --git a/noncore/games/solitaire/card.h b/noncore/games/solitaire/card.h index eb30d30..68ce425 100644 --- a/noncore/games/solitaire/card.h +++ b/noncore/games/solitaire/card.h | |||
@@ -57,6 +57,9 @@ public: | |||
57 | bool isShowing() { return showing; } | 57 | bool isShowing() { return showing; } |
58 | bool isRed() { return ((suit == diamonds) || (suit == hearts)); } | 58 | bool isRed() { return ((suit == diamonds) || (suit == hearts)); } |
59 | 59 | ||
60 | int getDeckNumber() { return deckNumber; } | ||
61 | void setDeckNumber(int n) { deckNumber=n; } | ||
62 | |||
60 | int getX(void) { return ix; } | 63 | int getX(void) { return ix; } |
61 | int getY(void) { return iy; } | 64 | int getY(void) { return iy; } |
62 | int getZ(void) { return iz; } | 65 | int getZ(void) { return iz; } |
@@ -75,6 +78,7 @@ private: | |||
75 | eSuit suit; | 78 | eSuit suit; |
76 | bool faceUp; | 79 | bool faceUp; |
77 | bool showing; | 80 | bool showing; |
81 | int deckNumber; | ||
78 | int ix, iy, iz; | 82 | int ix, iy, iz; |
79 | CardPile *cardPile; | 83 | CardPile *cardPile; |
80 | }; | 84 | }; |
diff --git a/noncore/games/solitaire/carddeck.cpp b/noncore/games/solitaire/carddeck.cpp index 87c043a..a2d0076 100644 --- a/noncore/games/solitaire/carddeck.cpp +++ b/noncore/games/solitaire/carddeck.cpp | |||
@@ -23,7 +23,7 @@ | |||
23 | #include "carddeck.h" | 23 | #include "carddeck.h" |
24 | 24 | ||
25 | 25 | ||
26 | CardDeck::CardDeck(int jokers) : numberOfJokers(jokers), deckCreated(FALSE) | 26 | CardDeck::CardDeck(int jokers, int numOfDecks) : numberOfJokers(jokers), numberOfDecks(numOfDecks), deckCreated(FALSE) |
27 | { | 27 | { |
28 | cards = new (Card *)[getNumberOfCards()]; | 28 | cards = new (Card *)[getNumberOfCards()]; |
29 | } | 29 | } |
@@ -40,10 +40,14 @@ CardDeck::~CardDeck() | |||
40 | void CardDeck::createDeck() | 40 | void CardDeck::createDeck() |
41 | { | 41 | { |
42 | if (!deckCreated) { | 42 | if (!deckCreated) { |
43 | for (int i = 0; i < 52; i++) | 43 | for (int j = 0; j < getNumberOfDecks(); j++) { |
44 | cards[i] = newCard( (eValue)((i % 13) + 1), (eSuit)((i / 13) + 1), FALSE ); | 44 | for (int i = 0; i < 52; i++) { |
45 | cards[i+j*52] = newCard( (eValue)((i % 13) + 1), (eSuit)((i / 13) + 1), FALSE); | ||
46 | cards[i+j*52]->setDeckNumber(j); | ||
47 | } | ||
48 | } | ||
45 | for (int i = 0; i < getNumberOfJokers(); i++) | 49 | for (int i = 0; i < getNumberOfJokers(); i++) |
46 | cards[52 + i] = newCard( jokerVal, jokerSuit, FALSE ); | 50 | cards[52*getNumberOfDecks() + i] = newCard( jokerVal, jokerSuit, FALSE); |
47 | deckCreated = TRUE; | 51 | deckCreated = TRUE; |
48 | } | 52 | } |
49 | } | 53 | } |
@@ -63,17 +67,23 @@ void CardDeck::shuffle() | |||
63 | 67 | ||
64 | int CardDeck::getNumberOfCards() | 68 | int CardDeck::getNumberOfCards() |
65 | { | 69 | { |
66 | return 52 + getNumberOfJokers(); | 70 | return 52*getNumberOfDecks() + getNumberOfJokers(); |
67 | } | 71 | } |
68 | 72 | ||
69 | 73 | ||
74 | int CardDeck::getNumberOfDecks() | ||
75 | { | ||
76 | return numberOfDecks; | ||
77 | } | ||
78 | |||
79 | |||
70 | int CardDeck::getNumberOfJokers() | 80 | int CardDeck::getNumberOfJokers() |
71 | { | 81 | { |
72 | return numberOfJokers; | 82 | return numberOfJokers; |
73 | } | 83 | } |
74 | 84 | ||
75 | 85 | ||
76 | Card *CardDeck::newCard( eValue v, eSuit s, bool f ) | 86 | Card *CardDeck::newCard( eValue v, eSuit s, bool f) |
77 | { | 87 | { |
78 | return new Card(v, s, f); | 88 | return new Card(v, s, f); |
79 | } | 89 | } |
diff --git a/noncore/games/solitaire/carddeck.h b/noncore/games/solitaire/carddeck.h index 9ad35a9..026834f 100644 --- a/noncore/games/solitaire/carddeck.h +++ b/noncore/games/solitaire/carddeck.h | |||
@@ -27,12 +27,13 @@ class Card; | |||
27 | class CardDeck | 27 | class CardDeck |
28 | { | 28 | { |
29 | public: | 29 | public: |
30 | CardDeck(int jokers = 0); | 30 | CardDeck(int jokers = 0, int numOfDecks = 1); |
31 | virtual ~CardDeck(); | 31 | virtual ~CardDeck(); |
32 | 32 | ||
33 | void createDeck(); | 33 | void createDeck(); |
34 | void shuffle(); | 34 | void shuffle(); |
35 | int getNumberOfCards(); | 35 | int getNumberOfCards(); |
36 | int getNumberOfDecks(); | ||
36 | int getNumberOfJokers(); | 37 | int getNumberOfJokers(); |
37 | 38 | ||
38 | virtual Card *newCard( eValue v, eSuit s, bool f ); | 39 | virtual Card *newCard( eValue v, eSuit s, bool f ); |
@@ -41,6 +42,7 @@ public: | |||
41 | Card **cards; | 42 | Card **cards; |
42 | private: | 43 | private: |
43 | int numberOfJokers; | 44 | int numberOfJokers; |
45 | int numberOfDecks; | ||
44 | bool deckCreated; | 46 | bool deckCreated; |
45 | }; | 47 | }; |
46 | 48 | ||
diff --git a/noncore/games/solitaire/cardgame.h b/noncore/games/solitaire/cardgame.h index dd7efab..2e37c7f 100644 --- a/noncore/games/solitaire/cardgame.h +++ b/noncore/games/solitaire/cardgame.h | |||
@@ -31,7 +31,7 @@ | |||
31 | class CardGame : public CardGameLayout, public CardDeck | 31 | class CardGame : public CardGameLayout, public CardDeck |
32 | { | 32 | { |
33 | public: | 33 | public: |
34 | CardGame(int numOfJokers = 0) : CardGameLayout(), CardDeck(numOfJokers) { } | 34 | CardGame(int numOfJokers = 0, int numOfDecks = 1) : CardGameLayout(), CardDeck(numOfJokers,numOfDecks) { } |
35 | virtual ~CardGame() { } | 35 | virtual ~CardGame() { } |
36 | virtual void newGame(); | 36 | virtual void newGame(); |
37 | virtual void mousePress(QPoint p) { Q_UNUSED(p); } | 37 | virtual void mousePress(QPoint p) { Q_UNUSED(p); } |
diff --git a/noncore/games/solitaire/cardpile.cpp b/noncore/games/solitaire/cardpile.cpp index 0b738d2..3b15e93 100644 --- a/noncore/games/solitaire/cardpile.cpp +++ b/noncore/games/solitaire/cardpile.cpp | |||
@@ -102,7 +102,7 @@ void CardPile::writeConfig( Config& cfg, QString name ) { | |||
102 | while ( card ) { | 102 | while ( card ) { |
103 | QString cardStr; | 103 | QString cardStr; |
104 | cardStr.sprintf( "%i", numberOfCards ); | 104 | cardStr.sprintf( "%i", numberOfCards ); |
105 | int val = (int)card->getValue() - 1 + ( (int)card->getSuit() - 1 ) * 13; | 105 | int val = (int)card->getValue()-1 + ((int)card->getSuit()-1)*13 + (int)card->getDeckNumber()*52; |
106 | cfg.writeEntry( "Card" + cardStr, val ); | 106 | cfg.writeEntry( "Card" + cardStr, val ); |
107 | cfg.writeEntry( "CardFacing" + cardStr, card->isFacing() ); | 107 | cfg.writeEntry( "CardFacing" + cardStr, card->isFacing() ); |
108 | card = cardInfront( card ); | 108 | card = cardInfront( card ); |
diff --git a/noncore/games/solitaire/chicanecardgame.cpp b/noncore/games/solitaire/chicanecardgame.cpp new file mode 100644 index 0000000..a242419 --- a/dev/null +++ b/noncore/games/solitaire/chicanecardgame.cpp | |||
@@ -0,0 +1,171 @@ | |||
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 "chicanecardgame.h" | ||
25 | |||
26 | |||
27 | extern int highestZ; | ||
28 | |||
29 | |||
30 | ChicaneCardGame::ChicaneCardGame(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 ChicaneDiscardPile( 27 + i * 26, 10, canvas() ); | ||
36 | addCardPile(discardPiles[i]); | ||
37 | } | ||
38 | for (int i = 0; i < 8; i++) { | ||
39 | workingPiles[i] = new ChicaneWorkingPile( 27 + i * 26, 50, canvas() ); | ||
40 | addCardPile(workingPiles[i]); | ||
41 | } | ||
42 | faceDownDealingPile = new ChicaneFaceDownDeck( 2, 10, canvas() ); | ||
43 | } | ||
44 | |||
45 | |||
46 | void ChicaneCardGame::deal(void) | ||
47 | { | ||
48 | highestZ = 1; | ||
49 | int t = 0; | ||
50 | |||
51 | beginDealing(); | ||
52 | |||
53 | for (int i = 0; i < 8; i++) { | ||
54 | for (int k = 0; k < 4; k++, t++) { | ||
55 | Card *card = cards[t]; | ||
56 | workingPiles[i]->addCardToTop(card); | ||
57 | card->setCardPile( workingPiles[i] ); | ||
58 | card->setPos( 0, 0, highestZ ); | ||
59 | card->setFace(k==3); | ||
60 | card->move( workingPiles[i]->getCardPos( card ) ); | ||
61 | card->showCard(); | ||
62 | highestZ++; | ||
63 | } | ||
64 | } | ||
65 | |||
66 | for ( ; t < getNumberOfCards(); t++) { | ||
67 | Card *card = cards[t]; | ||
68 | faceDownDealingPile->addCardToTop(card); | ||
69 | card->setCardPile( faceDownDealingPile ); | ||
70 | QPoint p = faceDownDealingPile->getCardPos( card ); | ||
71 | card->setPos( p.x(), p.y(), highestZ ); | ||
72 | card->showCard(); | ||
73 | highestZ++; | ||
74 | } | ||
75 | |||
76 | endDealing(); | ||
77 | } | ||
78 | |||
79 | |||
80 | void ChicaneCardGame::readConfig( Config& cfg ) | ||
81 | { | ||
82 | cfg.setGroup("GameState"); | ||
83 | |||
84 | // Create Cards, but don't shuffle or deal them yet | ||
85 | createDeck(); | ||
86 | |||
87 | // Move the cards to their piles (deal them to their previous places) | ||
88 | beginDealing(); | ||
89 | |||
90 | highestZ = 1; | ||
91 | |||
92 | for (int i = 0; i < 8; i++) { | ||
93 | QString pile; | ||
94 | pile.sprintf( "ChicaneDiscardPile%i", i ); | ||
95 | readPile( cfg, discardPiles[i], pile, highestZ ); | ||
96 | } | ||
97 | |||
98 | for (int i = 0; i < 8; i++) { | ||
99 | QString pile; | ||
100 | pile.sprintf( "ChicaneWorkingPile%i", i ); | ||
101 | readPile( cfg, workingPiles[i], pile, highestZ ); | ||
102 | } | ||
103 | |||
104 | readPile( cfg, faceDownDealingPile, "ChicaneFaceDownDealingPile", highestZ ); | ||
105 | |||
106 | highestZ++; | ||
107 | |||
108 | endDealing(); | ||
109 | } | ||
110 | |||
111 | |||
112 | void ChicaneCardGame::writeConfig( Config& cfg ) | ||
113 | { | ||
114 | cfg.setGroup("GameState"); | ||
115 | for ( int i = 0; i < 8; i++ ) { | ||
116 | QString pile; | ||
117 | pile.sprintf( "ChicaneDiscardPile%i", i ); | ||
118 | discardPiles[i]->writeConfig( cfg, pile ); | ||
119 | } | ||
120 | for ( int i = 0; i < 8; i++ ) { | ||
121 | QString pile; | ||
122 | pile.sprintf( "ChicaneWorkingPile%i", i ); | ||
123 | workingPiles[i]->writeConfig( cfg, pile ); | ||
124 | } | ||
125 | faceDownDealingPile->writeConfig( cfg, "ChicaneFaceDownDealingPile" ); | ||
126 | } | ||
127 | |||
128 | |||
129 | bool ChicaneCardGame::mousePressCard( Card *card, QPoint p ) | ||
130 | { | ||
131 | Q_UNUSED(p); | ||
132 | |||
133 | CanvasCard *item = (CanvasCard *)card; | ||
134 | if (item->isFacing() != TRUE) { | ||
135 | // From facedown stack | ||
136 | if ((item->x() == 2) && ((int)item->y() == 10)) { // Deal a row of 8 cards | ||
137 | // Move 8 cards, one to each workingPile | ||
138 | beginDealing(); | ||
139 | for (int i=0; i<8 && faceDownDealingPile->cardOnTop(); i++) { | ||
140 | CanvasCard *card = (CanvasCard *)faceDownDealingPile->cardOnTop(); | ||
141 | card->setZ(highestZ); | ||
142 | highestZ++; | ||
143 | faceDownDealingPile->removeCard(card); | ||
144 | workingPiles[i]->addCardToTop(card); | ||
145 | card->setCardPile( workingPiles[i] ); | ||
146 | card->setFace(FALSE); | ||
147 | QPoint p = workingPiles[i]->getCardPos(card); | ||
148 | card->flipTo( p.x(), p.y() ); | ||
149 | } | ||
150 | endDealing(); | ||
151 | } | ||
152 | moving = NULL; | ||
153 | moved = FALSE; | ||
154 | |||
155 | return TRUE; | ||
156 | } else if ( !card->getCardPile()->isAllowedToBeMoved(card) ) {// Don't allow unclean columns to be moved | ||
157 | moving = NULL; | ||
158 | return TRUE; | ||
159 | } | ||
160 | |||
161 | return FALSE; | ||
162 | } | ||
163 | |||
164 | |||
165 | |||
166 | void ChicaneCardGame::mousePress(QPoint p) | ||
167 | { | ||
168 | Q_UNUSED(p); | ||
169 | } | ||
170 | |||
171 | |||
diff --git a/noncore/games/solitaire/chicanecardgame.h b/noncore/games/solitaire/chicanecardgame.h new file mode 100644 index 0000000..668f5f4 --- a/dev/null +++ b/noncore/games/solitaire/chicanecardgame.h | |||
@@ -0,0 +1,165 @@ | |||
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 CHICANE_CARD_GAME_H | ||
21 | #define CHICANE_CARD_GAME_H | ||
22 | |||
23 | |||
24 | #include "patiencecardgame.h" | ||
25 | |||
26 | |||
27 | class ChicaneFaceDownDeck : public PatienceFaceDownDeck | ||
28 | { | ||
29 | public: | ||
30 | ChicaneFaceDownDeck(int x, int y, QCanvas *canvas) : | ||
31 | PatienceFaceDownDeck(x, y, canvas) { } | ||
32 | |||
33 | }; | ||
34 | |||
35 | |||
36 | class ChicaneDiscardPile : public PatienceDiscardPile | ||
37 | { | ||
38 | public: | ||
39 | ChicaneDiscardPile(int x, int y, QCanvas *canvas) : | ||
40 | PatienceDiscardPile(x, y, canvas) { } | ||
41 | |||
42 | }; | ||
43 | |||
44 | |||
45 | class ChicaneWorkingPile : public PatienceWorkingPile | ||
46 | { | ||
47 | public: | ||
48 | ChicaneWorkingPile(int x, int y, QCanvas *canvas) : | ||
49 | PatienceWorkingPile(x, y, canvas) { } | ||
50 | |||
51 | virtual bool isAllowedOnTop(Card *card) { | ||
52 | if ( card->isFacing() && | ||
53 | // ( ( ( cardOnTop() == NULL ) && (card->getValue() == king) ) || // diese Zeile sorgt dafür dass nur Kings auf leere Plätze dürfen | ||
54 | ( (cardOnTop() == NULL) || // auf einen Freiplatz darf alles! | ||
55 | ( (cardOnTop() != NULL) && | ||
56 | ((int)card->getValue() + 1 == (int)cardOnTop()->getValue()) && | ||
57 | (card->isRed() != cardOnTop()->isRed()) ) ) ) | ||
58 | return TRUE; | ||
59 | return FALSE; | ||
60 | } | ||
61 | virtual bool isAllowedToBeMoved(Card *card) { | ||
62 | if (!card->isFacing()) return FALSE; | ||
63 | |||
64 | int nextExpectedValue = (int)card->getValue(); | ||
65 | bool nextExpectedColor = card->isRed(); | ||
66 | |||
67 | while ((card != NULL)) { | ||
68 | if ( (int)card->getValue() != nextExpectedValue ) | ||
69 | return FALSE; | ||
70 | if ( card->isRed() != nextExpectedColor ) | ||
71 | return FALSE; | ||
72 | nextExpectedValue--;; | ||
73 | nextExpectedColor = !nextExpectedColor; | ||
74 | card = cardInfront(card); | ||
75 | } | ||
76 | return TRUE; | ||
77 | } | ||
78 | |||
79 | virtual void cardRemoved(Card *card) { | ||
80 | Q_UNUSED(card); | ||
81 | |||
82 | Card *newTopCard = cardOnTop(); | ||
83 | |||
84 | if ( !newTopCard ) { | ||
85 | top = QPoint( pileX, pileY ); | ||
86 | setNextX( pileX ); | ||
87 | setNextY( pileY ); | ||
88 | return; | ||
89 | } else { | ||
90 | top = getCardPos(NULL); | ||
91 | if ( newTopCard->isFacing() == FALSE ) { | ||
92 | int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; | ||
93 | // correct the position taking in to account the card is not | ||
94 | // yet flipped, but will become flipped | ||
95 | top = QPoint( top.x(), top.y() - 3 ); // Keine Verschiebung! | ||
96 | newTopCard->flipTo( top.x(), top.y() ); | ||
97 | top = QPoint( top.x(), top.y() + offsetDown ); | ||
98 | } | ||
99 | setNextX( top.x() ); | ||
100 | setNextY( top.y() ); | ||
101 | } | ||
102 | } | ||
103 | virtual QPoint getCardPos(Card *c) { | ||
104 | int x = pileX, y = pileY; | ||
105 | Card *card = cardOnBottom(); | ||
106 | while ((card != c) && (card != NULL)) { | ||
107 | if (card->isFacing()) { | ||
108 | int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; | ||
109 | y += offsetDown; | ||
110 | } else { | ||
111 | x += 0; // Keine Verschiebung! | ||
112 | y += 3; | ||
113 | } | ||
114 | card = cardInfront(card); | ||
115 | } | ||
116 | return QPoint( x, y ); | ||
117 | } | ||
118 | |||
119 | virtual QPoint getHypertheticalNextCardPos(void) { | ||
120 | // return top; | ||
121 | return QPoint( getNextX(), getNextY() ); | ||
122 | } | ||
123 | |||
124 | private: | ||
125 | QPoint top; | ||
126 | |||
127 | }; | ||
128 | |||
129 | |||
130 | class ChicaneCardGame : public CanvasCardGame | ||
131 | { | ||
132 | public: | ||
133 | ChicaneCardGame(QCanvas *c, bool snap, QWidget *parent = 0); | ||
134 | // virtual ~ChicaneCardGame(); | ||
135 | virtual void deal(void); | ||
136 | virtual bool haveWeWon() { | ||
137 | return ( discardPiles[0]->kingOnTop() && | ||
138 | discardPiles[1]->kingOnTop() && | ||
139 | discardPiles[2]->kingOnTop() && | ||
140 | discardPiles[3]->kingOnTop() && | ||
141 | discardPiles[4]->kingOnTop() && | ||
142 | discardPiles[5]->kingOnTop() && | ||
143 | discardPiles[6]->kingOnTop() && | ||
144 | discardPiles[7]->kingOnTop() );; | ||
145 | } | ||
146 | virtual void mousePress(QPoint p); | ||
147 | virtual void mouseRelease(QPoint p) { Q_UNUSED(p); } | ||
148 | // virtual void mouseMove(QPoint p); | ||
149 | virtual bool mousePressCard(Card *card, QPoint p); | ||
150 | 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); } | ||
152 | bool canTurnOverDeck(void) { return (FALSE); } | ||
153 | void throughDeck(void) { } | ||
154 | bool snapOn; | ||
155 | void writeConfig( Config& cfg ); | ||
156 | void readConfig( Config& cfg ); | ||
157 | private: | ||
158 | ChicaneWorkingPile *workingPiles[8]; | ||
159 | ChicaneDiscardPile *discardPiles[8]; | ||
160 | ChicaneFaceDownDeck *faceDownDealingPile; | ||
161 | }; | ||
162 | |||
163 | |||
164 | #endif | ||
165 | |||
diff --git a/noncore/games/solitaire/harpcardgame.cpp b/noncore/games/solitaire/harpcardgame.cpp new file mode 100644 index 0000000..22715ec --- a/dev/null +++ b/noncore/games/solitaire/harpcardgame.cpp | |||
@@ -0,0 +1,171 @@ | |||
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 "harpcardgame.h" | ||
25 | |||
26 | |||
27 | extern int highestZ; | ||
28 | |||
29 | |||
30 | HarpCardGame::HarpCardGame(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 HarpDiscardPile( 27 + i * 26, 10, canvas() ); | ||
36 | addCardPile(discardPiles[i]); | ||
37 | } | ||
38 | for (int i = 0; i < 8; i++) { | ||
39 | workingPiles[i] = new HarpWorkingPile( 27 + i * 26, 50, canvas() ); | ||
40 | addCardPile(workingPiles[i]); | ||
41 | } | ||
42 | faceDownDealingPile = new HarpFaceDownDeck( 2, 10, canvas() ); | ||
43 | } | ||
44 | |||
45 | |||
46 | void HarpCardGame::deal(void) | ||
47 | { | ||
48 | highestZ = 1; | ||
49 | int t = 0; | ||
50 | |||
51 | beginDealing(); | ||
52 | |||
53 | for (int i = 0; i < 8; i++) { | ||
54 | for (int k = 0; k < i+1; k++, t++) { | ||
55 | Card *card = cards[t]; | ||
56 | workingPiles[i]->addCardToTop(card); | ||
57 | card->setCardPile( workingPiles[i] ); | ||
58 | card->setPos( 0, 0, highestZ ); | ||
59 | card->setFace(k==i); | ||
60 | card->move( workingPiles[i]->getCardPos( card ) ); | ||
61 | card->showCard(); | ||
62 | highestZ++; | ||
63 | } | ||
64 | } | ||
65 | |||
66 | for ( ; t < getNumberOfCards(); t++) { | ||
67 | Card *card = cards[t]; | ||
68 | faceDownDealingPile->addCardToTop(card); | ||
69 | card->setCardPile( faceDownDealingPile ); | ||
70 | QPoint p = faceDownDealingPile->getCardPos( card ); | ||
71 | card->setPos( p.x(), p.y(), highestZ ); | ||
72 | card->showCard(); | ||
73 | highestZ++; | ||
74 | } | ||
75 | |||
76 | endDealing(); | ||
77 | } | ||
78 | |||
79 | |||
80 | void HarpCardGame::readConfig( Config& cfg ) | ||
81 | { | ||
82 | cfg.setGroup("GameState"); | ||
83 | |||
84 | // Create Cards, but don't shuffle or deal them yet | ||
85 | createDeck(); | ||
86 | |||
87 | // Move the cards to their piles (deal them to their previous places) | ||
88 | beginDealing(); | ||
89 | |||
90 | highestZ = 1; | ||
91 | |||
92 | for (int i = 0; i < 8; i++) { | ||
93 | QString pile; | ||
94 | pile.sprintf( "HarpDiscardPile%i", i ); | ||
95 | readPile( cfg, discardPiles[i], pile, highestZ ); | ||
96 | } | ||
97 | |||
98 | for (int i = 0; i < 8; i++) { | ||
99 | QString pile; | ||
100 | pile.sprintf( "HarpWorkingPile%i", i ); | ||
101 | readPile( cfg, workingPiles[i], pile, highestZ ); | ||
102 | } | ||
103 | |||
104 | readPile( cfg, faceDownDealingPile, "HarpFaceDownDealingPile", highestZ ); | ||
105 | |||
106 | highestZ++; | ||
107 | |||
108 | endDealing(); | ||
109 | } | ||
110 | |||
111 | |||
112 | void HarpCardGame::writeConfig( Config& cfg ) | ||
113 | { | ||
114 | cfg.setGroup("GameState"); | ||
115 | for ( int i = 0; i < 8; i++ ) { | ||
116 | QString pile; | ||
117 | pile.sprintf( "HarpDiscardPile%i", i ); | ||
118 | discardPiles[i]->writeConfig( cfg, pile ); | ||
119 | } | ||
120 | for ( int i = 0; i < 8; i++ ) { | ||
121 | QString pile; | ||
122 | pile.sprintf( "HarpWorkingPile%i", i ); | ||
123 | workingPiles[i]->writeConfig( cfg, pile ); | ||
124 | } | ||
125 | faceDownDealingPile->writeConfig( cfg, "HarpFaceDownDealingPile" ); | ||
126 | } | ||
127 | |||
128 | |||
129 | bool HarpCardGame::mousePressCard( Card *card, QPoint p ) | ||
130 | { | ||
131 | Q_UNUSED(p); | ||
132 | |||
133 | CanvasCard *item = (CanvasCard *)card; | ||
134 | if (item->isFacing() != TRUE) { | ||
135 | // From facedown stack | ||
136 | if ((item->x() == 2) && ((int)item->y() == 10)) { // Deal a row of 8 cards | ||
137 | // Move 8 cards, one to each workingPile | ||
138 | beginDealing(); | ||
139 | for (int i=0; i<8 && faceDownDealingPile->cardOnTop(); i++) { | ||
140 | CanvasCard *card = (CanvasCard *)faceDownDealingPile->cardOnTop(); | ||
141 | card->setZ(highestZ); | ||
142 | highestZ++; | ||
143 | faceDownDealingPile->removeCard(card); | ||
144 | workingPiles[i]->addCardToTop(card); | ||
145 | card->setCardPile( workingPiles[i] ); | ||
146 | card->setFace(FALSE); | ||
147 | QPoint p = workingPiles[i]->getCardPos(card); | ||
148 | card->flipTo( p.x(), p.y() ); | ||
149 | } | ||
150 | endDealing(); | ||
151 | } | ||
152 | moving = NULL; | ||
153 | moved = FALSE; | ||
154 | |||
155 | return TRUE; | ||
156 | } else if ( !card->getCardPile()->isAllowedToBeMoved(card) ) {// Don't allow unclean columns to be moved | ||
157 | moving = NULL; | ||
158 | return TRUE; | ||
159 | } | ||
160 | |||
161 | return FALSE; | ||
162 | } | ||
163 | |||
164 | |||
165 | |||
166 | void HarpCardGame::mousePress(QPoint p) | ||
167 | { | ||
168 | Q_UNUSED(p); | ||
169 | } | ||
170 | |||
171 | |||
diff --git a/noncore/games/solitaire/harpcardgame.h b/noncore/games/solitaire/harpcardgame.h new file mode 100644 index 0000000..d1733fd --- a/dev/null +++ b/noncore/games/solitaire/harpcardgame.h | |||
@@ -0,0 +1,165 @@ | |||
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 HARP_CARD_GAME_H | ||
21 | #define HARP_CARD_GAME_H | ||
22 | |||
23 | |||
24 | #include "patiencecardgame.h" | ||
25 | |||
26 | |||
27 | class HarpFaceDownDeck : public PatienceFaceDownDeck | ||
28 | { | ||
29 | public: | ||
30 | HarpFaceDownDeck(int x, int y, QCanvas *canvas) : | ||
31 | PatienceFaceDownDeck(x, y, canvas) { } | ||
32 | |||
33 | }; | ||
34 | |||
35 | |||
36 | class HarpDiscardPile : public PatienceDiscardPile | ||
37 | { | ||
38 | public: | ||
39 | HarpDiscardPile(int x, int y, QCanvas *canvas) : | ||
40 | PatienceDiscardPile(x, y, canvas) { } | ||
41 | |||
42 | }; | ||
43 | |||
44 | |||
45 | class HarpWorkingPile : public PatienceWorkingPile | ||
46 | { | ||
47 | public: | ||
48 | HarpWorkingPile(int x, int y, QCanvas *canvas) : | ||
49 | PatienceWorkingPile(x, y, canvas) { } | ||
50 | |||
51 | virtual bool isAllowedOnTop(Card *card) { | ||
52 | if ( card->isFacing() && | ||
53 | // ( ( ( cardOnTop() == NULL ) && (card->getValue() == king) ) || // diese Zeile sorgt dafür dass nur Kings auf leere Plätze dürfen | ||
54 | ( (cardOnTop() == NULL) || // auf einen Freiplatz darf alles! | ||
55 | ( (cardOnTop() != NULL) && | ||
56 | ((int)card->getValue() + 1 == (int)cardOnTop()->getValue()) && | ||
57 | (card->isRed() != cardOnTop()->isRed()) ) ) ) | ||
58 | return TRUE; | ||
59 | return FALSE; | ||
60 | } | ||
61 | virtual bool isAllowedToBeMoved(Card *card) { | ||
62 | if (!card->isFacing()) return FALSE; | ||
63 | |||
64 | int nextExpectedValue = (int)card->getValue(); | ||
65 | bool nextExpectedColor = card->isRed(); | ||
66 | |||
67 | while ((card != NULL)) { | ||
68 | if ( (int)card->getValue() != nextExpectedValue ) | ||
69 | return FALSE; | ||
70 | if ( card->isRed() != nextExpectedColor ) | ||
71 | return FALSE; | ||
72 | nextExpectedValue--;; | ||
73 | nextExpectedColor = !nextExpectedColor; | ||
74 | card = cardInfront(card); | ||
75 | } | ||
76 | return TRUE; | ||
77 | } | ||
78 | |||
79 | virtual void cardRemoved(Card *card) { | ||
80 | Q_UNUSED(card); | ||
81 | |||
82 | Card *newTopCard = cardOnTop(); | ||
83 | |||
84 | if ( !newTopCard ) { | ||
85 | top = QPoint( pileX, pileY ); | ||
86 | setNextX( pileX ); | ||
87 | setNextY( pileY ); | ||
88 | return; | ||
89 | } else { | ||
90 | top = getCardPos(NULL); | ||
91 | if ( newTopCard->isFacing() == FALSE ) { | ||
92 | int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; | ||
93 | // correct the position taking in to account the card is not | ||
94 | // yet flipped, but will become flipped | ||
95 | top = QPoint( top.x(), top.y() - 3 ); // Keine Verschiebung! | ||
96 | newTopCard->flipTo( top.x(), top.y() ); | ||
97 | top = QPoint( top.x(), top.y() + offsetDown ); | ||
98 | } | ||
99 | setNextX( top.x() ); | ||
100 | setNextY( top.y() ); | ||
101 | } | ||
102 | } | ||
103 | virtual QPoint getCardPos(Card *c) { | ||
104 | int x = pileX, y = pileY; | ||
105 | Card *card = cardOnBottom(); | ||
106 | while ((card != c) && (card != NULL)) { | ||
107 | if (card->isFacing()) { | ||
108 | int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; | ||
109 | y += offsetDown; | ||
110 | } else { | ||
111 | x += 0; // Keine Verschiebung! | ||
112 | y += 3; | ||
113 | } | ||
114 | card = cardInfront(card); | ||
115 | } | ||
116 | return QPoint( x, y ); | ||
117 | } | ||
118 | |||
119 | virtual QPoint getHypertheticalNextCardPos(void) { | ||
120 | // return top; | ||
121 | return QPoint( getNextX(), getNextY() ); | ||
122 | } | ||
123 | |||
124 | private: | ||
125 | QPoint top; | ||
126 | |||
127 | }; | ||
128 | |||
129 | |||
130 | class HarpCardGame : public CanvasCardGame | ||
131 | { | ||
132 | public: | ||
133 | HarpCardGame(QCanvas *c, bool snap, QWidget *parent = 0); | ||
134 | // virtual ~HarpCardGame(); | ||
135 | virtual void deal(void); | ||
136 | virtual bool haveWeWon() { | ||
137 | return ( discardPiles[0]->kingOnTop() && | ||
138 | discardPiles[1]->kingOnTop() && | ||
139 | discardPiles[2]->kingOnTop() && | ||
140 | discardPiles[3]->kingOnTop() && | ||
141 | discardPiles[4]->kingOnTop() && | ||
142 | discardPiles[5]->kingOnTop() && | ||
143 | discardPiles[6]->kingOnTop() && | ||
144 | discardPiles[7]->kingOnTop() );; | ||
145 | } | ||
146 | virtual void mousePress(QPoint p); | ||
147 | virtual void mouseRelease(QPoint p) { Q_UNUSED(p); } | ||
148 | // virtual void mouseMove(QPoint p); | ||
149 | virtual bool mousePressCard(Card *card, QPoint p); | ||
150 | 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); } | ||
152 | bool canTurnOverDeck(void) { return (FALSE); } | ||
153 | void throughDeck(void) { } | ||
154 | bool snapOn; | ||
155 | void writeConfig( Config& cfg ); | ||
156 | void readConfig( Config& cfg ); | ||
157 | private: | ||
158 | HarpWorkingPile *workingPiles[8]; | ||
159 | HarpDiscardPile *discardPiles[8]; | ||
160 | HarpFaceDownDeck *faceDownDealingPile; | ||
161 | }; | ||
162 | |||
163 | |||
164 | #endif | ||
165 | |||
diff --git a/noncore/games/solitaire/patiencecardgame.cpp b/noncore/games/solitaire/patiencecardgame.cpp index fc91b26..1b38072 100644 --- a/noncore/games/solitaire/patiencecardgame.cpp +++ b/noncore/games/solitaire/patiencecardgame.cpp | |||
@@ -194,10 +194,8 @@ bool PatienceCardGame::mousePressCard( Card *card, QPoint p ) | |||
194 | item->flipTo( 30, (int)item->y() ); | 194 | item->flipTo( 30, (int)item->y() ); |
195 | else | 195 | else |
196 | item->flipTo( 35, (int)item->y() ); | 196 | item->flipTo( 35, (int)item->y() ); |
197 | } else { | 197 | } else return FALSE; // <- was missing, caused facedown card to react |
198 | // fix from cmader by tille | 198 | // to clicking, which is wrong |
199 | return false; | ||
200 | } | ||
201 | moving = NULL; | 199 | moving = NULL; |
202 | moved = FALSE; | 200 | moved = FALSE; |
203 | 201 | ||
diff --git a/noncore/games/solitaire/solitaire.pro b/noncore/games/solitaire/solitaire.pro index 01d87ed..b2ba5aa 100755 --- a/noncore/games/solitaire/solitaire.pro +++ b/noncore/games/solitaire/solitaire.pro | |||
@@ -1,8 +1,11 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | HEADERS = canvascard.h canvasshapes.h cardgame.h cardgamelayout.h cardpile.h card.h carddeck.h canvascardgame.h freecellcardgame.h patiencecardgame.h canvascardwindow.h | 4 | |
5 | SOURCES = canvascard.cpp canvasshapes.cpp cardgame.cpp cardgamelayout.cpp cardpile.cpp card.cpp carddeck.cpp canvascardgame.cpp freecellcardgame.cpp patiencecardgame.cpp canvascardwindow.cpp main.cpp | 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 | |||
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 | |||
6 | TARGET = patience | 9 | TARGET = patience |
7 | INCLUDEPATH += $(OPIEDIR)/include | 10 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH+= $(OPIEDIR)/include | 11 | DEPENDPATH+= $(OPIEDIR)/include |