summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/solitaire/canvascardgame.cpp4
-rw-r--r--noncore/games/solitaire/canvascardgame.h3
-rw-r--r--noncore/games/solitaire/canvascardwindow.cpp53
-rw-r--r--noncore/games/solitaire/canvascardwindow.h2
-rw-r--r--noncore/games/solitaire/card.h4
-rw-r--r--noncore/games/solitaire/carddeck.cpp22
-rw-r--r--noncore/games/solitaire/carddeck.h4
-rw-r--r--noncore/games/solitaire/cardgame.h2
-rw-r--r--noncore/games/solitaire/cardpile.cpp2
-rw-r--r--noncore/games/solitaire/chicanecardgame.cpp171
-rw-r--r--noncore/games/solitaire/chicanecardgame.h165
-rw-r--r--noncore/games/solitaire/harpcardgame.cpp171
-rw-r--r--noncore/games/solitaire/harpcardgame.h165
-rw-r--r--noncore/games/solitaire/patiencecardgame.cpp6
-rwxr-xr-xnoncore/games/solitaire/solitaire.pro7
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
@@ -365,14 +365,16 @@ void CanvasCardGame::readPile( Config& cfg, CardPile *pile, QString name, int& h
{
cfg.setGroup( name );
int numberOfCards = cfg.readNumEntry("NumberOfCards", 0);
Card *card = NULL;
+
for ( int i = 0; i < numberOfCards; i++ ) {
QString cardStr;
cardStr.sprintf( "%i", i );
int val = cfg.readNumEntry( "Card" + cardStr );
bool facing = cfg.readBoolEntry( "CardFacing" + cardStr );
- card = cards[ val ];
+
+ card = cards[ val ];
card->setFace(facing);
pile->addCardToTop(card);
card->setCardPile(pile);
QPoint p = pile->getCardPos( card );
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
@@ -40,10 +40,11 @@ class CanvasCardPile;
class CanvasCardGame : public QCanvasView, public CardGame
{
public:
- CanvasCardGame(QCanvas &c, bool snap, QWidget *parent = 0, const char *name = 0, WFlags f = 0) :
+ CanvasCardGame(QCanvas &c, bool snap, QWidget *parent = 0, int numOfDecks = 1, const char *name = 0, WFlags f = 0) :
QCanvasView( &c, parent, name, f ),
+ CardGame(0,numOfDecks),
moved(FALSE),
moving(NULL),
alphaCardPile( NULL ),
cardXOff(0), cardYOff(0),
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
@@ -20,8 +20,10 @@
#include "canvascardwindow.h"
#include "patiencecardgame.h"
#include "freecellcardgame.h"
+#include "chicanecardgame.h"
+#include "harpcardgame.h"
#include <qpe/resource.h>
#include <qmainwindow.h>
@@ -58,8 +60,10 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f)
QPopupMenu* file = new QPopupMenu;
file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F);
file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F);
+ file->insertItem(tr("Chicane"), this, SLOT(initChicane()), CTRL+Key_F);
+ file->insertItem(tr("Harp"), this, SLOT(initHarp()), CTRL+Key_F);
menu->insertItem(tr("&Game"), file);
menu->insertSeparator();
@@ -80,8 +84,10 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f)
QPopupMenu* file = new QPopupMenu;
file->insertItem(tr("Patience"), this, SLOT(initPatience()));
file->insertItem(tr("Freecell"), this, SLOT(initFreecell()));
+ file->insertItem(tr("Chicane"), this, SLOT(initChicane()));
+ file->insertItem(tr("Harp"), this, SLOT(initHarp()));
menu->insertItem(tr("Play"), file);
menu->insertSeparator();
@@ -117,8 +123,24 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f)
setCentralWidget(cardGame);
//cardGame->newGame(); // Until we know how to handle reading freecell config
cardGame->readConfig( cfg );
setCardBacks();
+ } else if ( gameType == 2 ) {
+ cardGame = new ChicaneCardGame( &canvas, snapOn, this );
+ cardGame->setNumberToDraw(1);
+ setCaption(tr("Chicane"));
+ setCentralWidget(cardGame);
+ //cardGame->newGame(); // Until we know how to handle reading freecell config
+ cardGame->readConfig( cfg );
+ setCardBacks();
+ } else if ( gameType == 3 ) {
+ cardGame = new HarpCardGame( &canvas, snapOn, this );
+ cardGame->setNumberToDraw(1);
+ setCaption(tr("Harp"));
+ setCentralWidget(cardGame);
+ //cardGame->newGame(); // Until we know how to handle reading freecell config
+ cardGame->readConfig( cfg );
+ setCardBacks();
} else {
// Probably there isn't a config file or it is broken
// Start a new game
initPatience();
@@ -180,8 +202,39 @@ void CanvasCardWindow::initFreecell()
setCardBacks();
}
+void CanvasCardWindow::initChicane()
+{
+ // Create New Game
+ if ( cardGame ) {
+ delete cardGame;
+ }
+ cardGame = new ChicaneCardGame( &canvas, snapOn, this );
+ cardGame->setNumberToDraw(1);
+ gameType = 2;
+ setCaption(tr("Chicane"));
+ setCentralWidget(cardGame);
+ cardGame->newGame();
+ setCardBacks();
+}
+
+void CanvasCardWindow::initHarp()
+{
+ // Create New Game
+ if ( cardGame ) {
+ delete cardGame;
+ }
+ cardGame = new HarpCardGame( &canvas, snapOn, this );
+ cardGame->setNumberToDraw(1);
+ gameType = 3;
+ setCaption(tr("Harp"));
+ setCentralWidget(cardGame);
+ cardGame->newGame();
+ setCardBacks();
+}
+
+
void CanvasCardWindow::snapToggle()
{
snapOn = !snapOn;
settings->setItemChecked(snap_id, 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
@@ -44,8 +44,10 @@ public slots:
private slots:
void initFreecell();
void initPatience();
+ void initChicane();
+ void initHarp();
protected:
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
@@ -56,8 +56,11 @@ public:
bool isShowing() { return showing; }
bool isRed() { return ((suit == diamonds) || (suit == hearts)); }
+ int getDeckNumber() { return deckNumber; }
+ void setDeckNumber(int n) { deckNumber=n; }
+
int getX(void) { return ix; }
int getY(void) { return iy; }
int getZ(void) { return iz; }
void flip(void) { flipTo(getX(), getY()); }
@@ -74,8 +77,9 @@ private:
eValue val;
eSuit suit;
bool faceUp;
bool showing;
+ int deckNumber;
int ix, iy, iz;
CardPile *cardPile;
};
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
@@ -22,9 +22,9 @@
#include "card.h"
#include "carddeck.h"
-CardDeck::CardDeck(int jokers) : numberOfJokers(jokers), deckCreated(FALSE)
+CardDeck::CardDeck(int jokers, int numOfDecks) : numberOfJokers(jokers), numberOfDecks(numOfDecks), deckCreated(FALSE)
{
cards = new (Card *)[getNumberOfCards()];
}
@@ -39,12 +39,16 @@ CardDeck::~CardDeck()
void CardDeck::createDeck()
{
if (!deckCreated) {
- for (int i = 0; i < 52; i++)
- cards[i] = newCard( (eValue)((i % 13) + 1), (eSuit)((i / 13) + 1), FALSE );
+ for (int j = 0; j < getNumberOfDecks(); j++) {
+ for (int i = 0; i < 52; i++) {
+ cards[i+j*52] = newCard( (eValue)((i % 13) + 1), (eSuit)((i / 13) + 1), FALSE);
+ cards[i+j*52]->setDeckNumber(j);
+ }
+ }
for (int i = 0; i < getNumberOfJokers(); i++)
- cards[52 + i] = newCard( jokerVal, jokerSuit, FALSE );
+ cards[52*getNumberOfDecks() + i] = newCard( jokerVal, jokerSuit, FALSE);
deckCreated = TRUE;
}
}
@@ -62,19 +66,25 @@ void CardDeck::shuffle()
int CardDeck::getNumberOfCards()
{
- return 52 + getNumberOfJokers();
+ return 52*getNumberOfDecks() + getNumberOfJokers();
}
+int CardDeck::getNumberOfDecks()
+{
+ return numberOfDecks;
+}
+
+
int CardDeck::getNumberOfJokers()
{
return numberOfJokers;
}
-Card *CardDeck::newCard( eValue v, eSuit s, bool f )
+Card *CardDeck::newCard( eValue v, eSuit s, bool f)
{
return new Card(v, s, f);
}
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
@@ -26,22 +26,24 @@ class Card;
class CardDeck
{
public:
- CardDeck(int jokers = 0);
+ CardDeck(int jokers = 0, int numOfDecks = 1);
virtual ~CardDeck();
void createDeck();
void shuffle();
int getNumberOfCards();
+ int getNumberOfDecks();
int getNumberOfJokers();
virtual Card *newCard( eValue v, eSuit s, bool f );
virtual void deal() { }
Card **cards;
private:
int numberOfJokers;
+ int numberOfDecks;
bool deckCreated;
};
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
@@ -30,9 +30,9 @@
class CardGame : public CardGameLayout, public CardDeck
{
public:
- CardGame(int numOfJokers = 0) : CardGameLayout(), CardDeck(numOfJokers) { }
+ CardGame(int numOfJokers = 0, int numOfDecks = 1) : CardGameLayout(), CardDeck(numOfJokers,numOfDecks) { }
virtual ~CardGame() { }
virtual void newGame();
virtual void mousePress(QPoint p) { Q_UNUSED(p); }
virtual void mouseRelease(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
@@ -101,9 +101,9 @@ void CardPile::writeConfig( Config& cfg, QString name ) {
Card *card = cardOnBottom();
while ( card ) {
QString cardStr;
cardStr.sprintf( "%i", numberOfCards );
- int val = (int)card->getValue() - 1 + ( (int)card->getSuit() - 1 ) * 13;
+ int val = (int)card->getValue()-1 + ((int)card->getSuit()-1)*13 + (int)card->getDeckNumber()*52;
cfg.writeEntry( "Card" + cardStr, val );
cfg.writeEntry( "CardFacing" + cardStr, card->isFacing() );
card = cardInfront( card );
numberOfCards++;
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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** 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.
+**
+**
+** Modified by C.A.Mader 2002
+**
+**********************************************************************/
+#include <qgfx_qws.h>
+#include "chicanecardgame.h"
+
+
+extern int highestZ;
+
+
+ChicaneCardGame::ChicaneCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent, 2) // Use 2 Decks
+{
+ highestZ = 0;
+
+ for (int i = 0; i < 8; i++) {
+ discardPiles[i] = new ChicaneDiscardPile( 27 + i * 26, 10, canvas() );
+ addCardPile(discardPiles[i]);
+ }
+ for (int i = 0; i < 8; i++) {
+ workingPiles[i] = new ChicaneWorkingPile( 27 + i * 26, 50, canvas() );
+ addCardPile(workingPiles[i]);
+ }
+ faceDownDealingPile = new ChicaneFaceDownDeck( 2, 10, canvas() );
+}
+
+
+void ChicaneCardGame::deal(void)
+{
+ highestZ = 1;
+ int t = 0;
+
+ beginDealing();
+
+ for (int i = 0; i < 8; i++) {
+ for (int k = 0; k < 4; k++, t++) {
+ Card *card = cards[t];
+ workingPiles[i]->addCardToTop(card);
+ card->setCardPile( workingPiles[i] );
+ card->setPos( 0, 0, highestZ );
+ card->setFace(k==3);
+ card->move( workingPiles[i]->getCardPos( card ) );
+ card->showCard();
+ highestZ++;
+ }
+ }
+
+ for ( ; t < getNumberOfCards(); 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 ChicaneCardGame::readConfig( Config& cfg )
+{
+ cfg.setGroup("GameState");
+
+ // Create Cards, but don't shuffle or deal them yet
+ createDeck();
+
+ // Move the cards to their piles (deal them to their previous places)
+ beginDealing();
+
+ highestZ = 1;
+
+ for (int i = 0; i < 8; i++) {
+ QString pile;
+ pile.sprintf( "ChicaneDiscardPile%i", i );
+ readPile( cfg, discardPiles[i], pile, highestZ );
+ }
+
+ for (int i = 0; i < 8; i++) {
+ QString pile;
+ pile.sprintf( "ChicaneWorkingPile%i", i );
+ readPile( cfg, workingPiles[i], pile, highestZ );
+ }
+
+ readPile( cfg, faceDownDealingPile, "ChicaneFaceDownDealingPile", highestZ );
+
+ highestZ++;
+
+ endDealing();
+}
+
+
+void ChicaneCardGame::writeConfig( Config& cfg )
+{
+ cfg.setGroup("GameState");
+ for ( int i = 0; i < 8; i++ ) {
+ QString pile;
+ pile.sprintf( "ChicaneDiscardPile%i", i );
+ discardPiles[i]->writeConfig( cfg, pile );
+ }
+ for ( int i = 0; i < 8; i++ ) {
+ QString pile;
+ pile.sprintf( "ChicaneWorkingPile%i", i );
+ workingPiles[i]->writeConfig( cfg, pile );
+ }
+ faceDownDealingPile->writeConfig( cfg, "ChicaneFaceDownDealingPile" );
+}
+
+
+bool ChicaneCardGame::mousePressCard( Card *card, QPoint p )
+{
+ Q_UNUSED(p);
+
+ CanvasCard *item = (CanvasCard *)card;
+ if (item->isFacing() != TRUE) {
+ // From facedown stack
+ if ((item->x() == 2) && ((int)item->y() == 10)) { // Deal a row of 8 cards
+ // Move 8 cards, one to each workingPile
+ beginDealing();
+ for (int i=0; i<8 && faceDownDealingPile->cardOnTop(); i++) {
+ CanvasCard *card = (CanvasCard *)faceDownDealingPile->cardOnTop();
+ card->setZ(highestZ);
+ highestZ++;
+ faceDownDealingPile->removeCard(card);
+ workingPiles[i]->addCardToTop(card);
+ card->setCardPile( workingPiles[i] );
+ card->setFace(FALSE);
+ QPoint p = workingPiles[i]->getCardPos(card);
+ card->flipTo( p.x(), p.y() );
+ }
+ endDealing();
+ }
+ moving = NULL;
+ moved = FALSE;
+
+ return TRUE;
+ } else if ( !card->getCardPile()->isAllowedToBeMoved(card) ) { // Don't allow unclean columns to be moved
+ moving = NULL;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+
+void ChicaneCardGame::mousePress(QPoint p)
+{
+ Q_UNUSED(p);
+}
+
+
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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** 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.
+**
+**********************************************************************/
+#ifndef CHICANE_CARD_GAME_H
+#define CHICANE_CARD_GAME_H
+
+
+#include "patiencecardgame.h"
+
+
+class ChicaneFaceDownDeck : public PatienceFaceDownDeck
+{
+public:
+ ChicaneFaceDownDeck(int x, int y, QCanvas *canvas) :
+ PatienceFaceDownDeck(x, y, canvas) { }
+
+};
+
+
+class ChicaneDiscardPile : public PatienceDiscardPile
+{
+public:
+ ChicaneDiscardPile(int x, int y, QCanvas *canvas) :
+ PatienceDiscardPile(x, y, canvas) { }
+
+};
+
+
+class ChicaneWorkingPile : public PatienceWorkingPile
+{
+public:
+ ChicaneWorkingPile(int x, int y, QCanvas *canvas) :
+ PatienceWorkingPile(x, y, canvas) { }
+
+ virtual bool isAllowedOnTop(Card *card) {
+ if ( card->isFacing() &&
+// ( ( ( cardOnTop() == NULL ) && (card->getValue() == king) ) || // diese Zeile sorgt dafür dass nur Kings auf leere Plätze dürfen
+ ( (cardOnTop() == NULL) || // auf einen Freiplatz darf alles!
+ ( (cardOnTop() != NULL) &&
+ ((int)card->getValue() + 1 == (int)cardOnTop()->getValue()) &&
+ (card->isRed() != cardOnTop()->isRed()) ) ) )
+ return TRUE;
+ return FALSE;
+ }
+ virtual bool isAllowedToBeMoved(Card *card) {
+ if (!card->isFacing()) return FALSE;
+
+ int nextExpectedValue = (int)card->getValue();
+ bool nextExpectedColor = card->isRed();
+
+ while ((card != NULL)) {
+ if ( (int)card->getValue() != nextExpectedValue )
+ return FALSE;
+ if ( card->isRed() != nextExpectedColor )
+ return FALSE;
+ nextExpectedValue--;;
+ nextExpectedColor = !nextExpectedColor;
+ card = cardInfront(card);
+ }
+ return TRUE;
+ }
+
+ virtual void cardRemoved(Card *card) {
+ Q_UNUSED(card);
+
+ Card *newTopCard = cardOnTop();
+
+ if ( !newTopCard ) {
+ top = QPoint( pileX, pileY );
+ 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(), top.y() - 3 ); // Keine Verschiebung!
+ 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 += 0; // Keine Verschiebung!
+ y += 3;
+ }
+ card = cardInfront(card);
+ }
+ return QPoint( x, y );
+ }
+
+ virtual QPoint getHypertheticalNextCardPos(void) {
+// return top;
+ return QPoint( getNextX(), getNextY() );
+ }
+
+private:
+ QPoint top;
+
+};
+
+
+class ChicaneCardGame : public CanvasCardGame
+{
+public:
+ ChicaneCardGame(QCanvas *c, bool snap, QWidget *parent = 0);
+// virtual ~ChicaneCardGame();
+ virtual void deal(void);
+ virtual bool haveWeWon() {
+ return ( discardPiles[0]->kingOnTop() &&
+ discardPiles[1]->kingOnTop() &&
+ discardPiles[2]->kingOnTop() &&
+ discardPiles[3]->kingOnTop() &&
+ discardPiles[4]->kingOnTop() &&
+ discardPiles[5]->kingOnTop() &&
+ discardPiles[6]->kingOnTop() &&
+ discardPiles[7]->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 (FALSE); }
+ void throughDeck(void) { }
+ bool snapOn;
+ void writeConfig( Config& cfg );
+ void readConfig( Config& cfg );
+private:
+ ChicaneWorkingPile *workingPiles[8];
+ ChicaneDiscardPile *discardPiles[8];
+ ChicaneFaceDownDeck *faceDownDealingPile;
+};
+
+
+#endif
+
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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** 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.
+**
+**
+** Modified by C.A.Mader 2002
+**
+**********************************************************************/
+#include <qgfx_qws.h>
+#include "harpcardgame.h"
+
+
+extern int highestZ;
+
+
+HarpCardGame::HarpCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent, 2) // Use 2 Decks
+{
+ highestZ = 0;
+
+ for (int i = 0; i < 8; i++) {
+ discardPiles[i] = new HarpDiscardPile( 27 + i * 26, 10, canvas() );
+ addCardPile(discardPiles[i]);
+ }
+ for (int i = 0; i < 8; i++) {
+ workingPiles[i] = new HarpWorkingPile( 27 + i * 26, 50, canvas() );
+ addCardPile(workingPiles[i]);
+ }
+ faceDownDealingPile = new HarpFaceDownDeck( 2, 10, canvas() );
+}
+
+
+void HarpCardGame::deal(void)
+{
+ highestZ = 1;
+ int t = 0;
+
+ beginDealing();
+
+ for (int i = 0; i < 8; i++) {
+ for (int k = 0; k < i+1; k++, t++) {
+ Card *card = cards[t];
+ workingPiles[i]->addCardToTop(card);
+ card->setCardPile( workingPiles[i] );
+ card->setPos( 0, 0, highestZ );
+ card->setFace(k==i);
+ card->move( workingPiles[i]->getCardPos( card ) );
+ card->showCard();
+ highestZ++;
+ }
+ }
+
+ for ( ; t < getNumberOfCards(); 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 HarpCardGame::readConfig( Config& cfg )
+{
+ cfg.setGroup("GameState");
+
+ // Create Cards, but don't shuffle or deal them yet
+ createDeck();
+
+ // Move the cards to their piles (deal them to their previous places)
+ beginDealing();
+
+ highestZ = 1;
+
+ for (int i = 0; i < 8; i++) {
+ QString pile;
+ pile.sprintf( "HarpDiscardPile%i", i );
+ readPile( cfg, discardPiles[i], pile, highestZ );
+ }
+
+ for (int i = 0; i < 8; i++) {
+ QString pile;
+ pile.sprintf( "HarpWorkingPile%i", i );
+ readPile( cfg, workingPiles[i], pile, highestZ );
+ }
+
+ readPile( cfg, faceDownDealingPile, "HarpFaceDownDealingPile", highestZ );
+
+ highestZ++;
+
+ endDealing();
+}
+
+
+void HarpCardGame::writeConfig( Config& cfg )
+{
+ cfg.setGroup("GameState");
+ for ( int i = 0; i < 8; i++ ) {
+ QString pile;
+ pile.sprintf( "HarpDiscardPile%i", i );
+ discardPiles[i]->writeConfig( cfg, pile );
+ }
+ for ( int i = 0; i < 8; i++ ) {
+ QString pile;
+ pile.sprintf( "HarpWorkingPile%i", i );
+ workingPiles[i]->writeConfig( cfg, pile );
+ }
+ faceDownDealingPile->writeConfig( cfg, "HarpFaceDownDealingPile" );
+}
+
+
+bool HarpCardGame::mousePressCard( Card *card, QPoint p )
+{
+ Q_UNUSED(p);
+
+ CanvasCard *item = (CanvasCard *)card;
+ if (item->isFacing() != TRUE) {
+ // From facedown stack
+ if ((item->x() == 2) && ((int)item->y() == 10)) { // Deal a row of 8 cards
+ // Move 8 cards, one to each workingPile
+ beginDealing();
+ for (int i=0; i<8 && faceDownDealingPile->cardOnTop(); i++) {
+ CanvasCard *card = (CanvasCard *)faceDownDealingPile->cardOnTop();
+ card->setZ(highestZ);
+ highestZ++;
+ faceDownDealingPile->removeCard(card);
+ workingPiles[i]->addCardToTop(card);
+ card->setCardPile( workingPiles[i] );
+ card->setFace(FALSE);
+ QPoint p = workingPiles[i]->getCardPos(card);
+ card->flipTo( p.x(), p.y() );
+ }
+ endDealing();
+ }
+ moving = NULL;
+ moved = FALSE;
+
+ return TRUE;
+ } else if ( !card->getCardPile()->isAllowedToBeMoved(card) ) { // Don't allow unclean columns to be moved
+ moving = NULL;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+
+void HarpCardGame::mousePress(QPoint p)
+{
+ Q_UNUSED(p);
+}
+
+
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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** 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.
+**
+**********************************************************************/
+#ifndef HARP_CARD_GAME_H
+#define HARP_CARD_GAME_H
+
+
+#include "patiencecardgame.h"
+
+
+class HarpFaceDownDeck : public PatienceFaceDownDeck
+{
+public:
+ HarpFaceDownDeck(int x, int y, QCanvas *canvas) :
+ PatienceFaceDownDeck(x, y, canvas) { }
+
+};
+
+
+class HarpDiscardPile : public PatienceDiscardPile
+{
+public:
+ HarpDiscardPile(int x, int y, QCanvas *canvas) :
+ PatienceDiscardPile(x, y, canvas) { }
+
+};
+
+
+class HarpWorkingPile : public PatienceWorkingPile
+{
+public:
+ HarpWorkingPile(int x, int y, QCanvas *canvas) :
+ PatienceWorkingPile(x, y, canvas) { }
+
+ virtual bool isAllowedOnTop(Card *card) {
+ if ( card->isFacing() &&
+// ( ( ( cardOnTop() == NULL ) && (card->getValue() == king) ) || // diese Zeile sorgt dafür dass nur Kings auf leere Plätze dürfen
+ ( (cardOnTop() == NULL) || // auf einen Freiplatz darf alles!
+ ( (cardOnTop() != NULL) &&
+ ((int)card->getValue() + 1 == (int)cardOnTop()->getValue()) &&
+ (card->isRed() != cardOnTop()->isRed()) ) ) )
+ return TRUE;
+ return FALSE;
+ }
+ virtual bool isAllowedToBeMoved(Card *card) {
+ if (!card->isFacing()) return FALSE;
+
+ int nextExpectedValue = (int)card->getValue();
+ bool nextExpectedColor = card->isRed();
+
+ while ((card != NULL)) {
+ if ( (int)card->getValue() != nextExpectedValue )
+ return FALSE;
+ if ( card->isRed() != nextExpectedColor )
+ return FALSE;
+ nextExpectedValue--;;
+ nextExpectedColor = !nextExpectedColor;
+ card = cardInfront(card);
+ }
+ return TRUE;
+ }
+
+ virtual void cardRemoved(Card *card) {
+ Q_UNUSED(card);
+
+ Card *newTopCard = cardOnTop();
+
+ if ( !newTopCard ) {
+ top = QPoint( pileX, pileY );
+ 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(), top.y() - 3 ); // Keine Verschiebung!
+ 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 += 0; // Keine Verschiebung!
+ y += 3;
+ }
+ card = cardInfront(card);
+ }
+ return QPoint( x, y );
+ }
+
+ virtual QPoint getHypertheticalNextCardPos(void) {
+// return top;
+ return QPoint( getNextX(), getNextY() );
+ }
+
+private:
+ QPoint top;
+
+};
+
+
+class HarpCardGame : public CanvasCardGame
+{
+public:
+ HarpCardGame(QCanvas *c, bool snap, QWidget *parent = 0);
+// virtual ~HarpCardGame();
+ virtual void deal(void);
+ virtual bool haveWeWon() {
+ return ( discardPiles[0]->kingOnTop() &&
+ discardPiles[1]->kingOnTop() &&
+ discardPiles[2]->kingOnTop() &&
+ discardPiles[3]->kingOnTop() &&
+ discardPiles[4]->kingOnTop() &&
+ discardPiles[5]->kingOnTop() &&
+ discardPiles[6]->kingOnTop() &&
+ discardPiles[7]->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 (FALSE); }
+ void throughDeck(void) { }
+ bool snapOn;
+ void writeConfig( Config& cfg );
+ void readConfig( Config& cfg );
+private:
+ HarpWorkingPile *workingPiles[8];
+ HarpDiscardPile *discardPiles[8];
+ HarpFaceDownDeck *faceDownDealingPile;
+};
+
+
+#endif
+
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
@@ -193,12 +193,10 @@ bool PatienceCardGame::mousePressCard( Card *card, QPoint p )
if ( qt_screen->deviceWidth() < 200 )
item->flipTo( 30, (int)item->y() );
else
item->flipTo( 35, (int)item->y() );
- } else {
- // fix from cmader by tille
- return false;
- }
+ } 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
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,9 +1,12 @@
TEMPLATE = app
CONFIG += qt warn_on release
DESTDIR = $(OPIEDIR)/bin
-HEADERS = canvascard.h canvasshapes.h cardgame.h cardgamelayout.h cardpile.h card.h carddeck.h canvascardgame.h freecellcardgame.h patiencecardgame.h canvascardwindow.h
-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
+
+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
+
+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
+
TARGET = patience
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe