Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

card.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 #ifndef CARD_H
00021 #define CARD_H
00022 
00023 
00024 #include <qpoint.h>
00025 
00026 
00027 class CardPile;
00028 
00029 
00030 enum eSuit {
00031     jokerSuit = 0, clubs, spades, diamonds, hearts
00032 };
00033 
00034 
00035 enum eValue {
00036     jokerVal = 0, ace, two, three, four, five,
00037     six, seven, eight, nine, ten, jack, queen, king
00038 };
00039 
00040 
00041 class Card
00042 {
00043 public:
00044     Card( eValue v, eSuit s, bool f ) :
00045         val(v), suit(s), faceUp(f), showing(FALSE), ix(0), iy(0), iz(0), cardPile(NULL) { }
00046     virtual ~Card() { }
00047 
00048     eValue getValue() { return val; }
00049     eSuit getSuit() { return suit; }
00050 
00051     void setCardPile(CardPile *p) { cardPile = p; }
00052     CardPile *getCardPile() { return cardPile; }
00053 
00054     void setFace(bool f) { faceUp = f; /* flip(); */ }
00055     bool isFacing() { return faceUp; }
00056 
00057     bool isShowing() { return showing; }
00058     bool isRed() { return ((suit == diamonds) || (suit == hearts)); }
00059 
00060     int getDeckNumber() { return deckNumber; }
00061     void setDeckNumber(int n) { deckNumber=n; }
00062 
00063     int getX(void) { return ix; }
00064     int getY(void) { return iy; }
00065     int getZ(void) { return iz; }
00066     void flip(void) { flipTo(getX(), getY()); }
00067 
00068     virtual void setPos(int x, int y, int z) { ix = x; iy = y; iz = z; }
00069     virtual void move(int x, int y) { ix = x; iy = y; }
00070     virtual void move(QPoint p) { ix = p.x(); iy = p.y(); }
00071     virtual void flipTo(int x, int y, int steps = 8) { ix = x; iy = y; faceUp = !faceUp; redraw(); Q_UNUSED(steps); }
00072     virtual void showCard(void) { showing = TRUE; }
00073     virtual void hideCard(void) { showing = FALSE; }
00074 protected:
00075     virtual void redraw(void) { }
00076 private:
00077     eValue val;
00078     eSuit suit;
00079     bool faceUp;
00080     bool showing;
00081     int deckNumber;
00082     int ix, iy, iz;
00083     CardPile *cardPile;
00084 };
00085 
00086 
00087 #endif
00088 

Generated on Sat Nov 5 16:17:25 2005 for OPIE by  doxygen 1.4.2