-rw-r--r-- | noncore/games/solitaire/patiencecardgame.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/noncore/games/solitaire/patiencecardgame.cpp b/noncore/games/solitaire/patiencecardgame.cpp index a1e4968..00448ad 100644 --- a/noncore/games/solitaire/patiencecardgame.cpp +++ b/noncore/games/solitaire/patiencecardgame.cpp @@ -4,32 +4,33 @@ ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ + #include "patiencecardgame.h" int highestZ = 0; PatienceCardGame::PatienceCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent) { numberOfTimesThroughDeck = 0; highestZ = 0; if ( qt_screen->deviceWidth() < 200 ) { circleCross = new CanvasCircleOrCross( 7, 16, canvas() ); rectangle = new CanvasRoundRect( 30, 10, canvas() ); @@ -104,35 +105,37 @@ void PatienceCardGame::deal(void) faceDownDealingPile->addCardToTop(card); card->setCardPile( faceDownDealingPile ); QPoint p = faceDownDealingPile->getCardPos( card ); card->setPos( p.x(), p.y(), highestZ ); card->showCard(); highestZ++; } endDealing(); } void PatienceCardGame::readConfig( Config& cfg ) { cfg.setGroup("GameState"); - deckTurns = cfg.readNumEntry("DeckTurns", 2500); + // todo: make this eventually configurable + deckTurns = cfg.readNumEntry("DeckTurns", 2); // Do we have a config file to read in? - if ( !cfg.hasKey("numberOfTimesThroughDeck") ) { + if ( !cfg.hasKey("numberOfTimesThroughDeck") ) + { // if not, create a new game newGame(); return; } // We have a config file, lets read it in and use it // Create Cards, but don't shuffle or deal them yet createDeck(); // How many times through the deck have we been numberOfTimesThroughDeck = cfg.readNumEntry("numberOfTimesThroughDeck"); // restore state to the circle/cross under the dealing pile if ( canTurnOverDeck() ) circleCross->setCircle(); else @@ -263,26 +266,27 @@ void PatienceCardGame::mousePress(QPoint p) card->setPos( 5, 10, highestZ ); card->setFace( FALSE ); faceUpDealingPile->removeCard( card ); faceDownDealingPile->addCardToTop( card ); card->setCardPile( faceDownDealingPile ); card = faceUpDealingPile->cardOnTop(); highestZ++; } endDealing(); throughDeck(); moved = TRUE; } } - -bool PatienceCardGame::canTurnOverDeck() { +bool PatienceCardGame::canTurnOverDeck() +{ return (numberOfTimesThroughDeck != deckTurns); } -void PatienceCardGame::throughDeck() { +void PatienceCardGame::throughDeck() +{ numberOfTimesThroughDeck++; if (numberOfTimesThroughDeck == deckTurns) circleCross->setCross(); } |