diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | c90c389a8a8d9d8661e9772ec4144c5cf2039f23 (patch) | |
tree | 6d8391395bce9eaea4ad78958617edb20c6a7573 /kpat/pile.h | |
download | tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.tar.gz tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kpat/pile.h')
-rw-r--r-- | kpat/pile.h | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/kpat/pile.h b/kpat/pile.h new file mode 100644 index 00000000..b2b553b0 --- /dev/null +++ b/kpat/pile.h @@ -0,0 +1,154 @@ +#ifndef _PILE_H +#define _PILE_H + + +#include "card.h" +#include <kpixmap.h> + + +class Dealer; + + +/** + * + * Pile -- A pile on the board that can hold cards. + * + */ + +class Pile : public QObject, public QCanvasRectangle +{ + Q_OBJECT + +public: + + enum PileType { Custom, + KlondikeTarget, + KlondikeStore, + GypsyStore, + FreeCell, + FreecellStore}; + + // Add- and remove-flags + static const int Default; + static const int disallow; + static const int several; // default: move one card + + // Add-flags + static const int addSpread; + + // Remove-flags + static const int autoTurnTop; + static const int wholeColumn; + + Pile( int _index, Dealer* parent = 0); + virtual ~Pile(); + + Dealer *dealer() const { return m_dealer; } + CardList cards() const { return m_cards; } + + bool legalAdd(const CardList &c ) const; + bool legalRemove(const Card *c) const; + + virtual void moveCards(CardList &c, Pile *to = 0); + void moveCardsBack(CardList &c, bool anim = true); + + void setAddFlags( int flag ) { m_addFlags = flag; } + void setRemoveFlags( int flag ) { m_removeFlags = flag; } + + void setCheckIndex( int index ) { _checkIndex = index; } + virtual int checkIndex() const { return _checkIndex; } + + void setTarget(bool t) { _target = t; } + bool target() const { return _target; } + + CardList cardPressed(Card *c); + + Card *top() const; + + void add( Card *c, bool facedown, bool spread); // for initial deal + void add( Card *c, int index = -1); + void remove(Card *c); + void clear(); + + int index() const { return myIndex; } + bool isEmpty() const { return m_cards.count() == 0; } + + virtual void drawShape ( QPainter & p ); + static const int RTTI; + + virtual int rtti() const { return RTTI; } + + virtual void setVisible(bool vis); + virtual void moveBy(double dx, double dy); + + int cardsLeft() const { return m_cards.count(); } + + int indexOf(const Card *c) const; + Card *at(int index) const; + + void hideCards( const CardList & cards ); + void unhideCards( const CardList & cards ); + + virtual QSize cardOffset( bool _spread, bool _facedown, const Card *before) const; + + void resetCache(); + virtual void initSizes(); + + void setType( PileType t); + void setAddType( PileType t); + void setRemoveType( PileType t); + PileType addType() const { return m_atype; } + PileType removeType() const { return m_rtype; } + + // pile_algorithms + bool add_klondikeTarget( const CardList& c2 ) const; + bool add_klondikeStore( const CardList& c2 ) const; + bool add_gypsyStore( const CardList& c2 ) const; + bool add_freeCell( const CardList& c2) const; + + bool remove_freecellStore( const Card *c) const; + + // The spread properties. + int spread() const { return _spread; } + void setSpread(int s) { _spread = s; } + int dspread() const { return _dspread; } + void setDSpread(int s) { _dspread = s; } + int hspread() const { return _hspread; } + void setHSpread(int s) { _hspread = s; } + +public slots: + virtual bool cardClicked(Card *c); + virtual bool cardDblClicked(Card *c); + +signals: + void clicked(Card *c); + void dblClicked(Card *c); + +protected: + int m_removeFlags; + int m_addFlags; + CardList m_cards; + +private: + // Reference to the patience this pile is a part of. + Dealer *m_dealer; + + // Properties of the pile. + PileType m_atype; // Addtype + PileType m_rtype; // Removetype + int _spread; + int _hspread; + int _dspread; + + int _checkIndex; + int myIndex; + bool _target; + + // Graphics + KPixmap cache; + KPixmap cache_selected; +}; + +typedef QValueList<Pile*> PileList; + +#endif |