summaryrefslogtreecommitdiff
path: root/noncore/games/oyatzee/oyatzee.h
Unidiff
Diffstat (limited to 'noncore/games/oyatzee/oyatzee.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/games/oyatzee/oyatzee.h92
1 files changed, 68 insertions, 24 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
@@ -1,96 +1,116 @@
1#ifndef WORDGAME_H 1#ifndef WORDGAME_H
2#define WORDGAME_H 2#define WORDGAME_H
3 3
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()
10 12
11class Dice; 13class Dice;
12class Game; 14class Game;
13class Scoreboard; 15class Scoreboard;
14class DiceWidget; 16class DiceWidget;
15class Resultboard; 17class Resultboard;
16class Player; 18class Player;
17 19
20class QPoint;
21
18typedef QList<Dice> dicesList; 22typedef QList<Dice> dicesList;
19typedef QList<Resultboard> resultboardList; 23typedef QList<Resultboard> resultboardList;
20typedef QValueList<int> QValueListInt; 24typedef QValueList<int> QValueListInt;
21typedef QList<Player> playerList; 25typedef QList<Player> playerList;
26typedef QMap<int,int> pointMap;
22 27
23class OYatzee : public QMainWindow { 28class OYatzee : public QMainWindow {
24 Q_OBJECT 29 Q_OBJECT
25 public: 30 public:
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
63 */ 76 */
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
69class Dice : public QFrame 87class Dice : public QFrame
70{ 88{
71 Q_OBJECT 89 Q_OBJECT
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();
84 103
85 signals: 104 signals:
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
93class DiceWidget : public QWidget 113class DiceWidget : public QWidget
94{ 114{
95 Q_OBJECT 115 Q_OBJECT
96 public: 116 public:
@@ -98,39 +118,61 @@ class DiceWidget : public QWidget
98 118
99 QPushButton *rollButton; 119 QPushButton *rollButton;
100 120
101 dicesList diceList; 121 dicesList diceList;
102}; 122};
103 123
104
105class Board : public QWidget 124class 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
112class Possibilityboard : public Board 138class Possibilityboard : public Board
113{ 139{
114 Q_OBJECT 140 Q_OBJECT
115 141
116 public: 142 public:
117 Possibilityboard( QWidget *parent = 0, const char* name = 0 ); 143 Possibilityboard( QWidget *parent = 0, const char* name = 0 );
118 144
145 QValueListInt list;
146 void setIntlist( QValueListInt& );
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
123class Resultboard : public Board 161class Resultboard : public Board
124{ 162{
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};
134 176
135 177
136class Scoreboard : public QWidget 178class Scoreboard : public QWidget
@@ -142,33 +184,35 @@ 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);
147 189
190 Resultboard* nextRB(int);
191
192
148 protected: 193 protected:
149 void paintEvent( QPaintEvent *e ); 194 void paintEvent( QPaintEvent *e );
150}; 195};
151 196
152 197
153class Player 198class Player
154{ 199{
155 public: 200 public:
156 Player( QString name ); 201 Player( QString name );
157 202
158 QString playerName; 203 QString playerName;
159 int totalPoints; 204 int totalPoints;
160};
161 205
162class 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