author | cniehaus <cniehaus> | 2003-08-23 19:29:48 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2003-08-23 19:29:48 (UTC) |
commit | ff72e85696d070efa03975ea8130807579a6e1d9 (patch) (side-by-side diff) | |
tree | 4708b537f98915fd01aaeb856e5ad1c4db892ac6 /noncore/games/oyatzee/oyatzee.h | |
parent | 3dff9b4751fa9b63ddfd2527ec68add7fafb599d (diff) | |
download | opie-ff72e85696d070efa03975ea8130807579a6e1d9.zip opie-ff72e85696d070efa03975ea8130807579a6e1d9.tar.gz opie-ff72e85696d070efa03975ea8130807579a6e1d9.tar.bz2 |
working now. Almost 1500 lines diff
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 @@ -4,6 +4,8 @@ #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() @@ -15,10 +17,13 @@ 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 @@ -26,37 +31,45 @@ class OYatzee : public QMainWindow { 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 @@ -64,6 +77,11 @@ class OYatzee : public QMainWindow { void detectPosibilities(); void displayPossibilites(); + int getPoints( const int , QValueListInt ); + + void startGame(); + void stopGame(); + }; class Dice : public QFrame @@ -72,12 +90,13 @@ class Dice : public QFrame 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(); @@ -86,8 +105,9 @@ class Dice : public QFrame void selected(); protected: - void paintEvent( QPaintEvent *e ); + void paintEvent( QPaintEvent *e ); void paintNumber( QPainter *p ); + virtual void mousePressEvent( QMouseEvent* ); }; class DiceWidget : public QWidget @@ -101,12 +121,18 @@ 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 @@ -115,9 +141,21 @@ class Possibilityboard : public Board 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 @@ -125,9 +163,13 @@ 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 ); }; @@ -142,8 +184,11 @@ class Scoreboard : public QWidget Possibilityboard *pb; resultboardList rbList; playerList ps_; - + void createResultboards(const int); + + Resultboard* nextRB(int); + protected: void paintEvent( QPaintEvent *e ); @@ -157,18 +202,17 @@ class Player 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 |