-rw-r--r-- | noncore/games/solitaire/canvascardgame.cpp | 4 | ||||
-rw-r--r-- | noncore/games/solitaire/canvascardwindow.cpp | 28 | ||||
-rw-r--r-- | noncore/games/solitaire/canvascardwindow.h | 1 | ||||
-rw-r--r-- | noncore/games/solitaire/cardgamelayout.cpp | 2 | ||||
-rw-r--r-- | noncore/games/solitaire/cardpile.cpp | 3 | ||||
-rw-r--r-- | noncore/games/solitaire/cardpile.h | 14 | ||||
-rwxr-xr-x | noncore/games/solitaire/solitaire.pro | 35 | ||||
-rw-r--r-- | noncore/games/solitaire/teeclubcardgame.cpp | 194 | ||||
-rw-r--r-- | noncore/games/solitaire/teeclubcardgame.h | 217 |
9 files changed, 476 insertions, 22 deletions
diff --git a/noncore/games/solitaire/canvascardgame.cpp b/noncore/games/solitaire/canvascardgame.cpp index 357e798..4404b04 100644 --- a/noncore/games/solitaire/canvascardgame.cpp +++ b/noncore/games/solitaire/canvascardgame.cpp @@ -370,18 +370,18 @@ void CanvasCardGame::readPile( Config& cfg, CardPile *pile, QString name, int& h 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->setFace(facing); - pile->addCardToTop(card); - card->setCardPile(pile); + card->setCardPile(pile); // cam: setCardPile muss vor addCardToTop passieren + pile->addCardToTop(card); // weil sonst absturz wg cardAddedToTop QPoint p = pile->getCardPos( card ); card->setPos( p.x(), p.y(), highestZ ); card->showCard(); highestZ++; } } diff --git a/noncore/games/solitaire/canvascardwindow.cpp b/noncore/games/solitaire/canvascardwindow.cpp index e1c021e..450b4db 100644 --- a/noncore/games/solitaire/canvascardwindow.cpp +++ b/noncore/games/solitaire/canvascardwindow.cpp @@ -18,16 +18,17 @@ ** **********************************************************************/ #include "canvascardwindow.h" #include "patiencecardgame.h" #include "freecellcardgame.h" #include "chicanecardgame.h" #include "harpcardgame.h" +#include "teeclubcardgame.h" #include <qpe/resource.h> #include <qmainwindow.h> #include <qpopupmenu.h> #include <qstyle.h> @@ -58,16 +59,17 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) #ifdef _PATIENCE_USE_ACCELS_ QPEMenuBar* menu = menuBar(); 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); + file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()), CTRL+Key_F); menu->insertItem(tr("&Game"), file); menu->insertSeparator(); settings = new QPopupMenu; settings->insertItem(tr("&Change Card Backs"), this, SLOT(changeCardBacks()), Key_F2); snap_id = settings->insertItem(tr("&Snap To Position"), this, SLOT(snapToggle()), Key_F3); settings->setCheckable(TRUE); @@ -82,16 +84,17 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) #else QMenuBar* menu = menuBar(); 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())); + file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub())); menu->insertItem(tr("Play"), file); menu->insertSeparator(); settings = new QPopupMenu; settings->setCheckable(TRUE); settings->insertItem(tr("Change Card Backs"), this, SLOT(changeCardBacks())); snap_id = settings->insertItem(tr("Snap To Position"), this, SLOT(snapToggle())); @@ -124,25 +127,30 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) //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 if ( gameType == 4 ) { + cardGame = new TeeclubCardGame( &canvas, snapOn, this ); + cardGame->setNumberToDraw(1); + setCaption(tr("Teeclub")); + setCentralWidget(cardGame); cardGame->readConfig( cfg ); setCardBacks(); } else { // Probably there isn't a config file or it is broken // Start a new game initPatience(); } @@ -229,16 +237,32 @@ void CanvasCardWindow::initHarp() gameType = 3; setCaption(tr("Harp")); setCentralWidget(cardGame); cardGame->newGame(); setCardBacks(); } +void CanvasCardWindow::initTeeclub() +{ + // Create New Game + if ( cardGame ) { + delete cardGame; + } + cardGame = new TeeclubCardGame( &canvas, snapOn, this ); + cardGame->setNumberToDraw(1); + gameType = 4; + setCaption(tr("Teeclub")); + setCentralWidget(cardGame); + cardGame->newGame(); + setCardBacks(); +} + + void CanvasCardWindow::snapToggle() { snapOn = !snapOn; settings->setItemChecked(snap_id, snapOn); cardGame->toggleSnap(); } diff --git a/noncore/games/solitaire/canvascardwindow.h b/noncore/games/solitaire/canvascardwindow.h index aa76730..eddb184 100644 --- a/noncore/games/solitaire/canvascardwindow.h +++ b/noncore/games/solitaire/canvascardwindow.h @@ -42,16 +42,17 @@ public slots: void snapToggle(); void drawnToggle(); private slots: void initFreecell(); void initPatience(); void initChicane(); void initHarp(); + void initTeeclub(); protected: virtual void resizeEvent(QResizeEvent *e); void updateDraw(); private: QCanvas canvas; bool snapOn; diff --git a/noncore/games/solitaire/cardgamelayout.cpp b/noncore/games/solitaire/cardgamelayout.cpp index e21d08a..1ceee8d 100644 --- a/noncore/games/solitaire/cardgamelayout.cpp +++ b/noncore/games/solitaire/cardgamelayout.cpp @@ -13,17 +13,17 @@ ** ** 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 "cardgamelayout.h" -#include "card.h" + CardGameLayout::~CardGameLayout() { // Should I just do setAutoDelete( TRUE ); ? for (CardPile *p = first(); p != NULL; p = next()) delete p; } diff --git a/noncore/games/solitaire/cardpile.cpp b/noncore/games/solitaire/cardpile.cpp index 3b15e93..aace2e2 100644 --- a/noncore/games/solitaire/cardpile.cpp +++ b/noncore/games/solitaire/cardpile.cpp @@ -22,24 +22,25 @@ #include "card.h" #include <qpe/config.h> #include <qpoint.h> #include <qlist.h> -CardPile::CardPile(int x, int y) : pileX(x), pileY(y), dealing(FALSE) { +CardPile::CardPile(int x, int y) : pileX(x), pileY(y), dealing(FALSE), PileResize(FALSE) { pileWidth = 0; pileHeight = 0; pileNextX = pileX; pileNextY = pileY; pileCenterX = x + pileWidth / 2; pileCenterY = y + pileHeight / 2; pileRadius = (pileWidth > pileHeight) ? pileWidth : pileHeight; + pileOffsetDown = 13; } int CardPile::distanceFromPile(int x, int y) { return (pileCenterX-x)*(pileCenterX-x)+(pileCenterY-y)*(pileCenterY-y); } diff --git a/noncore/games/solitaire/cardpile.h b/noncore/games/solitaire/cardpile.h index c515bbc..1eb2499 100644 --- a/noncore/games/solitaire/cardpile.h +++ b/noncore/games/solitaire/cardpile.h @@ -46,27 +46,39 @@ public: virtual ~CardPile() { } int getX() { return pileX; } int getY() { return pileY; } int getNextX() { return pileNextX; } int getNextY() { return pileNextY; } int getWidth() { return pileWidth; } int getHeight() { return pileHeight; } + int getOffsetDown() { return pileOffsetDown; } + int getAnzCardsInPile() { + int anz=0; + Card *card = cardOnBottom(); + while (card != NULL) { anz++; card = cardInfront(card); } + return anz; + } void setX(int x) { pileX = x; } void setY(int y) { pileY = y; } void setNextX(int x) { pileNextX = x; } void setNextY(int y) { pileNextY = y; } void setWidth(int width) { pileWidth = width; } void setHeight(int height) { pileHeight = height; } + void setOffsetDown(int down) { pileOffsetDown = down; } void beginDealing() { dealing = TRUE; } void endDealing() { dealing = FALSE; } bool isDealing() { return dealing; } + + void beginPileResize() { PileResize = TRUE; } + void endPileResize() { PileResize = FALSE; } + bool isPileResize() { return PileResize; } int distanceFromPile(int x, int y); int distanceFromNextPos(int x, int y); Card *cardOnTop() { return getLast(); } Card *cardOnBottom() { return getFirst(); } Card *cardInfront(Card *c); bool kingOnTop(); @@ -87,15 +99,17 @@ public: void writeConfig( Config& cfg, QString name ); protected: int pileX, pileY; int pileNextX, pileNextY; int pileWidth, pileHeight; int pileCenterX, pileCenterY; int pileRadius; + int pileOffsetDown; private: bool dealing; + bool PileResize; }; #endif diff --git a/noncore/games/solitaire/solitaire.pro b/noncore/games/solitaire/solitaire.pro index b2ba5aa..d08dab0 100755 --- a/noncore/games/solitaire/solitaire.pro +++ b/noncore/games/solitaire/solitaire.pro @@ -1,28 +1,31 @@ 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 chicanecardgame.h harpcardgame.h patiencecardgame.h canvascardwindow.h +HEADERS = canvascard.h canvasshapes.h cardgame.h cardgamelayout.h cardpile.h card.h carddeck.h canvascardgame.h freecellcardgame.h chicanecardgame.h harpcardgame.h teeclubcardgame.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 +SOURCES = canvascard.cpp canvasshapes.cpp cardgame.cpp cardgamelayout.cpp cardpile.cpp card.cpp carddeck.cpp canvascardgame.cpp freecellcardgame.cpp chicanecardgame.cpp harpcardgame.cpp teeclubcardgame.cpp patiencecardgame.cpp canvascardwindow.cpp main.cpp TARGET = patience + INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe + REQUIRES = patience -TRANSLATIONS = ../../../i18n/de/patience.ts \ - ../../../i18n/en/patience.ts \ - ../../../i18n/es/patience.ts \ - ../../../i18n/fr/patience.ts \ - ../../../i18n/hu/patience.ts \ - ../../../i18n/ja/patience.ts \ - ../../../i18n/ko/patience.ts \ - ../../../i18n/no/patience.ts \ - ../../../i18n/pl/patience.ts \ - ../../../i18n/pt/patience.ts \ - ../../../i18n/pt_BR/patience.ts \ - ../../../i18n/sl/patience.ts \ - ../../../i18n/zh_CN/patience.ts \ - ../../../i18n/zh_TW/patience.ts +TRANSLATIONS = ../i18n/de/patience.ts +TRANSLATIONS += ../i18n/es/patience.ts +TRANSLATIONS += ../i18n/pt/patience.ts +TRANSLATIONS += ../i18n/pt_BR/patience.ts +TRANSLATIONS += ../i18n/en/patience.ts +TRANSLATIONS += ../i18n/hu/patience.ts +TRANSLATIONS += ../i18n/ja/patience.ts +TRANSLATIONS += ../i18n/sl/patience.ts +TRANSLATIONS += ../i18n/ko/patience.ts +TRANSLATIONS += ../i18n/pl/patience.ts +TRANSLATIONS += ../i18n/no/patience.ts +TRANSLATIONS += ../i18n/fr/patience.ts +TRANSLATIONS += ../i18n/zh_CN/patience.ts +TRANSLATIONS += ../i18n/zh_TW/patience.ts diff --git a/noncore/games/solitaire/teeclubcardgame.cpp b/noncore/games/solitaire/teeclubcardgame.cpp new file mode 100644 index 0000000..e15da96 --- a/dev/null +++ b/noncore/games/solitaire/teeclubcardgame.cpp @@ -0,0 +1,194 @@ +/********************************************************************** +** 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 "teeclubcardgame.h" + + +extern int highestZ; + + +TeeclubCardGame::TeeclubCardGame(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 TeeclubDiscardPile( 27 + i * 26, 10, canvas() ); + addCardPile(discardPiles[i]); + } + for (int i = 0; i < 9; i++) { + workingPiles[i] = new TeeclubWorkingPile( 2 + i * 26, 50, canvas() ); + addCardPile(workingPiles[i]); + } + faceDownDealingPile = new TeeclubFaceDownDeck( 2, 10, canvas() ); +} + + +void TeeclubCardGame::deal(void) +{ + highestZ = 1; + int t = 0; + + beginDealing(); + + for (int i = 0; i < 9; i++) { + workingPiles[i]->setOffsetDown(13); + workingPiles[i]->beginPileResize(); + for (int k = 0; k < 5; k++, t++) { + Card *card = cards[t]; + workingPiles[i]->addCardToTop(card); + card->setCardPile( workingPiles[i] ); + card->setPos( 0, 0, highestZ ); + card->setFace(TRUE); + 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 TeeclubCardGame::resizePiles() +{ + beginDealing(); + for (int i = 0; i < 9; i++) { + while ((workingPiles[i]->getCardPos(NULL).y() > 230) && (workingPiles[i]->getOffsetDown()>1)) { + // Resizen des Stapels + workingPiles[i]->setOffsetDown(workingPiles[i]->getOffsetDown()-1); + Card *card = workingPiles[i]->cardOnBottom(); + int p=0; + while (card != NULL) { + card->setPos( 0, 0, p++ ); + card->move( workingPiles[i]->getCardPos( card ) ); + card = workingPiles[i]->cardInfront(card); + } + } + } + endDealing(); +} + + +void TeeclubCardGame::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( "TeeclubDiscardPile%i", i ); + readPile( cfg, discardPiles[i], pile, highestZ ); + } + + for (int i = 0; i < 9; i++) { + workingPiles[i]->endPileResize(); + QString pile; + pile.sprintf( "TeeclubWorkingPile%i", i ); + readPile( cfg, workingPiles[i], pile, highestZ ); + workingPiles[i]->beginPileResize(); + } + + readPile( cfg, faceDownDealingPile, "TeeclubFaceDownDealingPile", highestZ ); + + highestZ++; + + endDealing(); + resizePiles(); +} + + +void TeeclubCardGame::writeConfig( Config& cfg ) +{ + cfg.setGroup("GameState"); + for ( int i = 0; i < 8; i++ ) { + QString pile; + pile.sprintf( "TeeclubDiscardPile%i", i ); + discardPiles[i]->writeConfig( cfg, pile ); + } + for ( int i = 0; i < 9; i++ ) { + QString pile; + pile.sprintf( "TeeclubWorkingPile%i", i ); + workingPiles[i]->writeConfig( cfg, pile ); + } + faceDownDealingPile->writeConfig( cfg, "TeeclubFaceDownDealingPile" ); +} + + +bool TeeclubCardGame::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 1 card + // Move 8 cards, one to each workingPile + beginDealing(); + CanvasCard *card = (CanvasCard *)faceDownDealingPile->cardOnTop(); + card->setZ(highestZ); + highestZ++; + faceDownDealingPile->removeCard(card); + workingPiles[0]->addCardToTop(card); + card->setCardPile( workingPiles[0] ); + card->setFace(FALSE); + QPoint p = workingPiles[0]->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 TeeclubCardGame::mousePress(QPoint p) +{ + Q_UNUSED(p); +} + + diff --git a/noncore/games/solitaire/teeclubcardgame.h b/noncore/games/solitaire/teeclubcardgame.h new file mode 100644 index 0000000..06d49f8 --- a/dev/null +++ b/noncore/games/solitaire/teeclubcardgame.h @@ -0,0 +1,217 @@ +/********************************************************************** +** 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 TEECLUB_CARD_GAME_H +#define TEECLUB_CARD_GAME_H + + +#include "patiencecardgame.h" + + +class TeeclubFaceDownDeck : public PatienceFaceDownDeck +{ +public: + TeeclubFaceDownDeck(int x, int y, QCanvas *canvas) : + PatienceFaceDownDeck(x, y, canvas) { } + +}; + + +class TeeclubDiscardPile : public CardPile, public CanvasRoundRect +{ +public: + TeeclubDiscardPile(int x, int y, QCanvas *canvas) + : CardPile(x, y), CanvasRoundRect(x, y, canvas) { } + virtual bool isAllowedOnTop(Card *card) { + if ( card->isFacing() && ( card->getCardPile()->cardInfront(card) == NULL ) && + ( ( ( cardOnTop() == NULL ) && ( card->getValue() == ace ) ) || + ( ( cardOnTop() != NULL ) && + ( (int)card->getValue() == (int)cardOnTop()->getValue() + 1 ) && + ( card->getSuit() == cardOnTop()->getSuit() ) ) ) ) + return TRUE; + return FALSE; + } + virtual bool isAllowedToBeMoved(Card *card) { + if (card->isFacing()) return FALSE; + return FALSE; // die Toten ruhn + } +}; + + +class TeeclubWorkingPile : public PatienceWorkingPile +{ +public: + TeeclubWorkingPile(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()) // bei teeclub sind die farben zum Anlegen egal + ) ) ) + return TRUE; + return FALSE; + } + + virtual bool isAllowedToBeMoved(Card *card) { + if (!card->isFacing()) return FALSE; + + int nextExpectedValue = (int)card->getValue(); + eSuit nextExpectedSuit = card->getSuit(); + + while ((card != NULL)) { + if ( (int)card->getValue() != nextExpectedValue ) + return FALSE; + if ( card->getSuit() != nextExpectedSuit ) + return FALSE; + nextExpectedValue--;; + 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 ); + setOffsetDown(13); + return; + } else { + top = getCardPos(NULL); + if ( newTopCard->isFacing() == FALSE ) { + int offsetDown = newTopCard->getCardPile()->getOffsetDown(); + // 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 seitliche Verschiebung! + newTopCard->flipTo( top.x(), top.y() ); + top = QPoint( top.x(), top.y() + offsetDown ); + } + setNextX( top.x() ); + setNextY( top.y() ); + } + + if ((getCardPos(NULL).y() < 230) && (getOffsetDown()<13)) { + // Resizen des Stapels + beginDealing(); + setOffsetDown(getOffsetDown()+1); + Card *card = cardOnBottom(); + int p=0; + while (card != NULL) { + card->setPos( 0, 0, p++ ); + card->move( getCardPos( card ) ); + card = cardInfront(card); + } + endDealing(); + } + } + + virtual QPoint getCardPos(Card *c) { + int x = pileX, y = pileY; + Card *card = cardOnBottom(); + while ((card != c) && (card != NULL)) { + if (card->isFacing()) { + int offsetDown = card->getCardPile()->getOffsetDown(); + y += offsetDown; + } else { + x += 0; // Keine seitliche Verschiebung! + y += 3; + } + card = cardInfront(card); + } + return QPoint( x, y ); + } + + virtual QPoint getHypertheticalNextCardPos(void) { + return QPoint( getNextX(), getNextY() ); + } + + virtual void cardAddedToTop(Card *c) { + Q_UNUSED(c); + setNextX( getCardPos(NULL).x() ); + setNextY( getCardPos(NULL).y() ); + + while (isPileResize() && (getCardPos(NULL).y() > 230) && (getOffsetDown()>1)) { + // Resizen des Stapels + beginDealing(); + setOffsetDown(getOffsetDown()-1); + Card *card = cardOnBottom(); + int p=0; + while (card != NULL) { + card->setPos( 0, 0, p++ ); + card->move( getCardPos( card ) ); + card = cardInfront(card); + } + endDealing(); + } + + } + + + + +private: + QPoint top; + +}; + + +class TeeclubCardGame : public CanvasCardGame +{ +public: + TeeclubCardGame(QCanvas *c, bool snap, QWidget *parent = 0); +// virtual ~TeeclubCardGame(); + 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 ); + void resizePiles(); +private: + TeeclubWorkingPile *workingPiles[9]; + TeeclubDiscardPile *discardPiles[8]; + TeeclubFaceDownDeck *faceDownDealingPile; +}; + + +#endif + |