Diffstat (limited to 'noncore/games/oyatzee/oyatzee.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/oyatzee/oyatzee.h | 98 |
1 files changed, 71 insertions, 27 deletions
diff --git a/noncore/games/oyatzee/oyatzee.h b/noncore/games/oyatzee/oyatzee.h index 1074f1d..048a733 100644 --- a/noncore/games/oyatzee/oyatzee.h +++ b/noncore/games/oyatzee/oyatzee.h @@ -3,8 +3,10 @@ #include <qmainwindow.h> #include <qlabel.h> #include <qlist.h> +#include <qmap.h> +#include <qsplitter.h> #include <stdlib.h> // rand() function #include <qdatetime.h> // seed for rand() @@ -14,81 +16,99 @@ class Scoreboard; class DiceWidget; class Resultboard; class Player; +class QPoint; + typedef QList<Dice> dicesList; typedef QList<Resultboard> resultboardList; typedef QValueList<int> QValueListInt; typedef QList<Player> playerList; +typedef QMap<int,int> pointMap; class OYatzee : public QMainWindow { Q_OBJECT public: OYatzee( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~OYatzee(); - Game *g; + Game *g(); DiceWidget *dw; Scoreboard *sb; QValueListInt posibilities; + playerList ps; void setPlayerNumber( const int num ); void setRoundsNumber( const int num ); - enum { - Ones=1, + enum { Ones = 1, Twos = 2, Threes = 3, Fours = 4, Fives = 5, Sixes = 6, - ThreeOfAKind = 7, //12444 - FourOfAKind = 8, //14444 - FullHouse = 9, //22555 - SStraight = 10, //13456 - LStraight = 11, //12345 - Yatzee = 12, //55555 - Chance = 13}; + ThreeOfAKind = 9, //12444 + FourOfAKind = 10, //14444 + FullHouse = 11, //22555 + SStraight = 12, //13456 + LStraight = 13, //12345 + Yatzee = 14, //55555 + Chance = 15}; public slots: void slotStartGame(); void slotRollDices(); + void slotEndRound( int ); private: int numOfPlayers; int numOfRounds; + int currentPlayer; /* the number of the current player */ + + int oakPoints; + + void nextPlayer(); + + bool lastPlayerFinished; /* * Check what posibilities the player currently has */ void detectPosibilities(); void displayPossibilites(); + int getPoints( const int , QValueListInt ); + + void startGame(); + void stopGame(); + }; class Dice : public QFrame { Q_OBJECT public: Dice( QWidget* parent = 0, const char* name = 0 ); - int Value; bool isSelected; - int hasValue(); + const int hasValue() const; void roll(); - virtual void mousePressEvent( QMouseEvent* ); + + private: + int Value; private slots: void slotSelected(); signals: void selected(); protected: - void paintEvent( QPaintEvent *e ); + void paintEvent( QPaintEvent *e ); void paintNumber( QPainter *p ); + virtual void mousePressEvent( QMouseEvent* ); }; class DiceWidget : public QWidget { @@ -100,35 +120,57 @@ class DiceWidget : public QWidget dicesList diceList; }; - class Board : public QWidget { Q_OBJECT public: Board( QWidget *parent = 0, const char* name = 0 ); + + signals: + void clicked( QPoint ); + void item( int ); + + protected: + virtual void mousePressEvent( QMouseEvent* ); }; class Possibilityboard : public Board { Q_OBJECT public: Possibilityboard( QWidget *parent = 0, const char* name = 0 ); + + QValueListInt list; + void setIntlist( QValueListInt& ); + private: + QStringList begriffe; + + private slots: + /* + * this slot returns the item the user has selected + */ + virtual void slotClicked(QPoint); + protected: - virtual void paintEvent( QPaintEvent *e ); + virtual void paintEvent( QPaintEvent *e ); }; class Resultboard : public Board { Q_OBJECT public: - Resultboard( QString playerName , QWidget *parent = 0, const char* name = 0 ); + Resultboard( QString playerName = 0 , QWidget *parent = 0, const char* name = 0 ); QString pName; + pointMap pMap; + + void updateMap( int, int ); + protected: virtual void paintEvent( QPaintEvent *e ); }; @@ -141,10 +183,13 @@ class Scoreboard : public QWidget Possibilityboard *pb; resultboardList rbList; playerList ps_; - + void createResultboards(const int); + + Resultboard* nextRB(int); + protected: void paintEvent( QPaintEvent *e ); }; @@ -156,19 +201,18 @@ class Player Player( QString name ); QString playerName; int totalPoints; -}; -class Game -{ - public: - Game( playerList pla ); + void setResults( const int , const int ); - playerList players; - int currentPlayer; + int turn; - void startGame(); - void stopGame(); + void updateTotalPoints( QMap<int,int> ); + + private: + QValueListInt pResults; /* the individual results of the player */ + + void setupResultList(); /* only in the ctor */ }; #endif // WORDGAME_H |