-rw-r--r-- | noncore/games/solitaire/patiencecardgame.cpp | 26 |
1 files changed, 15 insertions, 11 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 @@ -8,24 +8,25 @@ ** 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 ) @@ -108,27 +109,29 @@ void PatienceCardGame::deal(void) 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"); @@ -202,25 +205,25 @@ bool PatienceCardGame::mousePressCard( Card *card, QPoint p ) highestZ++; // Added Code faceDownDealingPile->removeCard(item); faceUpDealingPile->addCardToTop(item); item->setCardPile( faceUpDealingPile ); if ( qt_screen->deviceWidth() < 200 ) item->flipTo( 30, (int)item->y() ); else item->flipTo( 35, (int)item->y() ); } - else return FALSE; // <- was missing, caused facedown card to react + else return FALSE; // <- was missing, caused facedown card to react // to clicking, which is wrong moving = NULL; moved = FALSE; // move two other cards if we flip three at a time int flipped = 1; QCanvasItemList l = canvas()->collisions( p ); for (QCanvasItemList::Iterator it = l.begin(); (it != l.end()) && (flipped != cardsDrawn()); ++it) { if ( (*it)->rtti() == canvasCardId ) { CanvasCard *item = (CanvasCard *)*it; @@ -267,22 +270,23 @@ void PatienceCardGame::mousePress(QPoint p) card->setCardPile( faceDownDealingPile ); card = faceUpDealingPile->cardOnTop(); highestZ++; } endDealing(); throughDeck(); moved = TRUE; } } - -bool PatienceCardGame::canTurnOverDeck() { - return (numberOfTimesThroughDeck != deckTurns); +bool PatienceCardGame::canTurnOverDeck() +{ + return (numberOfTimesThroughDeck != deckTurns); } -void PatienceCardGame::throughDeck() { - numberOfTimesThroughDeck++; - if (numberOfTimesThroughDeck == deckTurns) - circleCross->setCross(); - } +void PatienceCardGame::throughDeck() +{ + numberOfTimesThroughDeck++; + if (numberOfTimesThroughDeck == deckTurns) + circleCross->setCross(); +} |