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 @@ | |||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qlist.h> | 6 | #include <qlist.h> |
7 | #include <qmap.h> | ||
8 | #include <qsplitter.h> | ||
7 | 9 | ||
8 | #include <stdlib.h> // rand() function | 10 | #include <stdlib.h> // rand() function |
9 | #include <qdatetime.h> // seed for rand() | 11 | #include <qdatetime.h> // seed for rand() |
@@ -15,10 +17,13 @@ class DiceWidget; | |||
15 | class Resultboard; | 17 | class Resultboard; |
16 | class Player; | 18 | class Player; |
17 | 19 | ||
20 | class QPoint; | ||
21 | |||
18 | typedef QList<Dice> dicesList; | 22 | typedef QList<Dice> dicesList; |
19 | typedef QList<Resultboard> resultboardList; | 23 | typedef QList<Resultboard> resultboardList; |
20 | typedef QValueList<int> QValueListInt; | 24 | typedef QValueList<int> QValueListInt; |
21 | typedef QList<Player> playerList; | 25 | typedef QList<Player> playerList; |
26 | typedef QMap<int,int> pointMap; | ||
22 | 27 | ||
23 | class OYatzee : public QMainWindow { | 28 | class OYatzee : public QMainWindow { |
24 | Q_OBJECT | 29 | Q_OBJECT |
@@ -26,37 +31,45 @@ class OYatzee : public QMainWindow { | |||
26 | OYatzee( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 31 | OYatzee( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
27 | ~OYatzee(); | 32 | ~OYatzee(); |
28 | 33 | ||
29 | Game *g; | 34 | Game *g(); |
30 | DiceWidget *dw; | 35 | DiceWidget *dw; |
31 | Scoreboard *sb; | 36 | Scoreboard *sb; |
32 | 37 | ||
33 | QValueListInt posibilities; | 38 | QValueListInt posibilities; |
39 | playerList ps; | ||
34 | 40 | ||
35 | void setPlayerNumber( const int num ); | 41 | void setPlayerNumber( const int num ); |
36 | void setRoundsNumber( const int num ); | 42 | void setRoundsNumber( const int num ); |
37 | 43 | ||
38 | enum { | 44 | enum { Ones = 1, |
39 | Ones=1, | ||
40 | Twos = 2, | 45 | Twos = 2, |
41 | Threes = 3, | 46 | Threes = 3, |
42 | Fours = 4, | 47 | Fours = 4, |
43 | Fives = 5, | 48 | Fives = 5, |
44 | Sixes = 6, | 49 | Sixes = 6, |
45 | ThreeOfAKind = 7, //12444 | 50 | ThreeOfAKind = 9, //12444 |
46 | FourOfAKind = 8, //14444 | 51 | FourOfAKind = 10, //14444 |
47 | FullHouse = 9, //22555 | 52 | FullHouse = 11, //22555 |
48 | SStraight = 10, //13456 | 53 | SStraight = 12, //13456 |
49 | LStraight = 11, //12345 | 54 | LStraight = 13, //12345 |
50 | Yatzee = 12, //55555 | 55 | Yatzee = 14, //55555 |
51 | Chance = 13}; | 56 | Chance = 15}; |
52 | 57 | ||
53 | public slots: | 58 | public slots: |
54 | void slotStartGame(); | 59 | void slotStartGame(); |
55 | void slotRollDices(); | 60 | void slotRollDices(); |
61 | void slotEndRound( int ); | ||
56 | 62 | ||
57 | private: | 63 | private: |
58 | int numOfPlayers; | 64 | int numOfPlayers; |
59 | int numOfRounds; | 65 | int numOfRounds; |
66 | int currentPlayer; /* the number of the current player */ | ||
67 | |||
68 | int oakPoints; | ||
69 | |||
70 | void nextPlayer(); | ||
71 | |||
72 | bool lastPlayerFinished; | ||
60 | 73 | ||
61 | /* | 74 | /* |
62 | * Check what posibilities the player currently has | 75 | * Check what posibilities the player currently has |
@@ -64,6 +77,11 @@ class OYatzee : public QMainWindow { | |||
64 | void detectPosibilities(); | 77 | void detectPosibilities(); |
65 | void displayPossibilites(); | 78 | void displayPossibilites(); |
66 | 79 | ||
80 | int getPoints( const int , QValueListInt ); | ||
81 | |||
82 | void startGame(); | ||
83 | void stopGame(); | ||
84 | |||
67 | }; | 85 | }; |
68 | 86 | ||
69 | class Dice : public QFrame | 87 | class Dice : public QFrame |
@@ -72,12 +90,13 @@ class Dice : public QFrame | |||
72 | public: | 90 | public: |
73 | Dice( QWidget* parent = 0, const char* name = 0 ); | 91 | Dice( QWidget* parent = 0, const char* name = 0 ); |
74 | 92 | ||
75 | int Value; | ||
76 | bool isSelected; | 93 | bool isSelected; |
77 | 94 | ||
78 | int hasValue(); | 95 | const int hasValue() const; |
79 | void roll(); | 96 | void roll(); |
80 | virtual void mousePressEvent( QMouseEvent* ); | 97 | |
98 | private: | ||
99 | int Value; | ||
81 | 100 | ||
82 | private slots: | 101 | private slots: |
83 | void slotSelected(); | 102 | void slotSelected(); |
@@ -86,8 +105,9 @@ class Dice : public QFrame | |||
86 | void selected(); | 105 | void selected(); |
87 | 106 | ||
88 | protected: | 107 | protected: |
89 | void paintEvent( QPaintEvent *e ); | 108 | void paintEvent( QPaintEvent *e ); |
90 | void paintNumber( QPainter *p ); | 109 | void paintNumber( QPainter *p ); |
110 | virtual void mousePressEvent( QMouseEvent* ); | ||
91 | }; | 111 | }; |
92 | 112 | ||
93 | class DiceWidget : public QWidget | 113 | class DiceWidget : public QWidget |
@@ -101,12 +121,18 @@ class DiceWidget : public QWidget | |||
101 | dicesList diceList; | 121 | dicesList diceList; |
102 | }; | 122 | }; |
103 | 123 | ||
104 | |||
105 | class Board : public QWidget | 124 | class Board : public QWidget |
106 | { | 125 | { |
107 | Q_OBJECT | 126 | Q_OBJECT |
108 | public: | 127 | public: |
109 | Board( QWidget *parent = 0, const char* name = 0 ); | 128 | Board( QWidget *parent = 0, const char* name = 0 ); |
129 | |||
130 | signals: | ||
131 | void clicked( QPoint ); | ||
132 | void item( int ); | ||
133 | |||
134 | protected: | ||
135 | virtual void mousePressEvent( QMouseEvent* ); | ||
110 | }; | 136 | }; |
111 | 137 | ||
112 | class Possibilityboard : public Board | 138 | class Possibilityboard : public Board |
@@ -115,9 +141,21 @@ class Possibilityboard : public Board | |||
115 | 141 | ||
116 | public: | 142 | public: |
117 | Possibilityboard( QWidget *parent = 0, const char* name = 0 ); | 143 | Possibilityboard( QWidget *parent = 0, const char* name = 0 ); |
144 | |||
145 | QValueListInt list; | ||
146 | void setIntlist( QValueListInt& ); | ||
118 | 147 | ||
148 | private: | ||
149 | QStringList begriffe; | ||
150 | |||
151 | private slots: | ||
152 | /* | ||
153 | * this slot returns the item the user has selected | ||
154 | */ | ||
155 | virtual void slotClicked(QPoint); | ||
156 | |||
119 | protected: | 157 | protected: |
120 | virtual void paintEvent( QPaintEvent *e ); | 158 | virtual void paintEvent( QPaintEvent *e ); |
121 | }; | 159 | }; |
122 | 160 | ||
123 | class Resultboard : public Board | 161 | class Resultboard : public Board |
@@ -125,9 +163,13 @@ class Resultboard : public Board | |||
125 | Q_OBJECT | 163 | Q_OBJECT |
126 | 164 | ||
127 | public: | 165 | public: |
128 | Resultboard( QString playerName , QWidget *parent = 0, const char* name = 0 ); | 166 | Resultboard( QString playerName = 0 , QWidget *parent = 0, const char* name = 0 ); |
129 | QString pName; | 167 | QString pName; |
130 | 168 | ||
169 | pointMap pMap; | ||
170 | |||
171 | void updateMap( int, int ); | ||
172 | |||
131 | protected: | 173 | protected: |
132 | virtual void paintEvent( QPaintEvent *e ); | 174 | virtual void paintEvent( QPaintEvent *e ); |
133 | }; | 175 | }; |
@@ -142,8 +184,11 @@ class Scoreboard : public QWidget | |||
142 | Possibilityboard *pb; | 184 | Possibilityboard *pb; |
143 | resultboardList rbList; | 185 | resultboardList rbList; |
144 | playerList ps_; | 186 | playerList ps_; |
145 | 187 | ||
146 | void createResultboards(const int); | 188 | void createResultboards(const int); |
189 | |||
190 | Resultboard* nextRB(int); | ||
191 | |||
147 | 192 | ||
148 | protected: | 193 | protected: |
149 | void paintEvent( QPaintEvent *e ); | 194 | void paintEvent( QPaintEvent *e ); |
@@ -157,18 +202,17 @@ class Player | |||
157 | 202 | ||
158 | QString playerName; | 203 | QString playerName; |
159 | int totalPoints; | 204 | int totalPoints; |
160 | }; | ||
161 | 205 | ||
162 | class Game | 206 | void setResults( const int , const int ); |
163 | { | ||
164 | public: | ||
165 | Game( playerList pla ); | ||
166 | 207 | ||
167 | playerList players; | 208 | int turn; |
168 | int currentPlayer; | ||
169 | 209 | ||
170 | void startGame(); | 210 | void updateTotalPoints( QMap<int,int> ); |
171 | void stopGame(); | 211 | |
212 | private: | ||
213 | QValueListInt pResults; /* the individual results of the player */ | ||
214 | |||
215 | void setupResultList(); /* only in the ctor */ | ||
172 | }; | 216 | }; |
173 | 217 | ||
174 | #endif // WORDGAME_H | 218 | #endif // WORDGAME_H |