author | llornkcor <llornkcor> | 2004-04-26 10:24:35 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-04-26 10:24:35 (UTC) |
commit | f6a98984fcb0dfc7e176636560b7cc1adacf38f2 (patch) (side-by-side diff) | |
tree | f358b16531551035a54c1dac95e16a36f86f8dc9 | |
parent | 57d7f3faf053786925d2315e43ab6ba8d892f51a (diff) | |
download | opie-f6a98984fcb0dfc7e176636560b7cc1adacf38f2.zip opie-f6a98984fcb0dfc7e176636560b7cc1adacf38f2.tar.gz opie-f6a98984fcb0dfc7e176636560b7cc1adacf38f2.tar.bz2 |
turn off silly casino rules solitare
-rw-r--r-- | noncore/games/solitaire/patiencecardgame.cpp | 13 | ||||
-rw-r--r-- | noncore/games/solitaire/patiencecardgame.h | 9 |
2 files changed, 14 insertions, 8 deletions
diff --git a/noncore/games/solitaire/patiencecardgame.cpp b/noncore/games/solitaire/patiencecardgame.cpp index 756577a..a1e4968 100644 --- a/noncore/games/solitaire/patiencecardgame.cpp +++ b/noncore/games/solitaire/patiencecardgame.cpp @@ -72,99 +72,99 @@ PatienceCardGame::~PatienceCardGame() delete circleCross; delete rectangle; delete faceDownDealingPile; delete faceUpDealingPile; } void PatienceCardGame::deal(void) { highestZ = 1; int t = 0; beginDealing(); for (int i = 0; i < 7; i++) { cards[t]->setFace(TRUE); for (int k = i; k < 7; k++, t++) { Card *card = cards[t]; workingPiles[k]->addCardToTop(card); card->setCardPile( workingPiles[k] ); QPoint p = workingPiles[k]->getCardPos( card ); card->setPos( p.x(), p.y(), highestZ ); card->showCard(); highestZ++; } } for ( ; t < 52; t++) { Card *card = cards[t]; 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); // 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 circleCross->setCross(); // Move the cards to their piles (deal them to their previous places) beginDealing(); highestZ = 1; for (int k = 0; k < 7; k++) { QString pile; pile.sprintf( "WorkingPile%i", k ); readPile( cfg, workingPiles[k], pile, highestZ ); } for (int k = 0; k < 4; k++) { QString pile; pile.sprintf( "DiscardPile%i", k ); readPile( cfg, discardPiles[k], pile, highestZ ); } readPile( cfg, faceDownDealingPile, "FaceDownDealingPile", highestZ ); readPile( cfg, faceUpDealingPile, "FaceUpDealingPile", highestZ ); highestZ++; endDealing(); } void PatienceCardGame::writeConfig( Config& cfg ) { @@ -232,48 +232,57 @@ bool PatienceCardGame::mousePressCard( Card *card, QPoint p ) // Added Code faceDownDealingPile->removeCard(item); faceUpDealingPile->addCardToTop(item); item->setCardPile( faceUpDealingPile ); if ( qt_screen->deviceWidth() < 200 ) item->flipTo( 30, (int)item->y(), 8 * flipped ); else item->flipTo( 35, (int)item->y(), 8 * flipped ); } } return TRUE; } return FALSE; } void PatienceCardGame::mousePress(QPoint p) { if ( canTurnOverDeck() && (p.x() > 5) && (p.x() < 28) && (p.y() > 10) && (p.y() < 46) ) { beginDealing(); Card *card = faceUpDealingPile->cardOnTop(); while ( card ) { 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() { + return (numberOfTimesThroughDeck != deckTurns); +} + +void PatienceCardGame::throughDeck() { + numberOfTimesThroughDeck++; + if (numberOfTimesThroughDeck == deckTurns) + circleCross->setCross(); + } diff --git a/noncore/games/solitaire/patiencecardgame.h b/noncore/games/solitaire/patiencecardgame.h index 0d0e3d5..b76251a 100644 --- a/noncore/games/solitaire/patiencecardgame.h +++ b/noncore/games/solitaire/patiencecardgame.h @@ -128,82 +128,79 @@ public: setNextX( pileX ); setNextY( pileY ); return; } else { top = getCardPos(NULL); if ( newTopCard->isFacing() == FALSE ) { int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; // correct the position taking in to account the card is not // yet flipped, but will become flipped top = QPoint( top.x() - 1, top.y() - 3 ); newTopCard->flipTo( top.x(), top.y() ); top = QPoint( top.x(), top.y() + offsetDown ); } setNextX( top.x() ); setNextY( top.y() ); } } virtual QPoint getCardPos(Card *c) { int x = pileX, y = pileY; Card *card = cardOnBottom(); while ((card != c) && (card != NULL)) { if (card->isFacing()) { int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; y += offsetDown; } else { x += 1; y += 3; } card = cardInfront(card); } return QPoint( x, y ); } virtual QPoint getHypertheticalNextCardPos(void) { return top; // return QPoint( getNextX(), getNextY() ); } private: QPoint top; }; class PatienceCardGame : public CanvasCardGame { public: PatienceCardGame(QCanvas *c, bool snap, QWidget *parent = 0); virtual ~PatienceCardGame(); virtual void deal(void); + int deckTurns; virtual bool haveWeWon() { return ( discardPiles[0]->kingOnTop() && discardPiles[1]->kingOnTop() && discardPiles[2]->kingOnTop() && discardPiles[3]->kingOnTop() );; } virtual void mousePress(QPoint p); virtual void mouseRelease(QPoint p) { Q_UNUSED(p); } // virtual void mouseMove(QPoint p); virtual bool mousePressCard(Card *card, QPoint p); virtual void mouseReleaseCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); } // virtual void mouseMoveCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); } - bool canTurnOverDeck(void) { return (numberOfTimesThroughDeck != 3); } - void throughDeck(void) { - numberOfTimesThroughDeck++; - if (numberOfTimesThroughDeck == 3) - circleCross->setCross(); - } + bool canTurnOverDeck(); + void throughDeck(); bool snapOn; virtual void writeConfig( Config& cfg ); virtual void readConfig( Config& cfg ); private: CanvasCircleOrCross *circleCross; CanvasRoundRect *rectangle; PatienceWorkingPile *workingPiles[7]; PatienceDiscardPile *discardPiles[4]; PatienceFaceDownDeck *faceDownDealingPile; PatienceFaceUpDeck *faceUpDealingPile; int numberOfTimesThroughDeck; }; #endif |