author | cniehaus <cniehaus> | 2003-08-13 14:53:18 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2003-08-13 14:53:18 (UTC) |
commit | 1b22b22d6e50b46f3ea04b5a1cfc3dc9bfd8a78a (patch) (unidiff) | |
tree | 327c797146d1a23cce2fdf558faa9ccacb9b6cf3 /noncore/games/oyatzee/oyatzee.h | |
parent | 6e7dbb9320256c326cd19e7555b4309e71d039e3 (diff) | |
download | opie-1b22b22d6e50b46f3ea04b5a1cfc3dc9bfd8a78a.zip opie-1b22b22d6e50b46f3ea04b5a1cfc3dc9bfd8a78a.tar.gz opie-1b22b22d6e50b46f3ea04b5a1cfc3dc9bfd8a78a.tar.bz2 |
well, a lot more is now implemented
Diffstat (limited to 'noncore/games/oyatzee/oyatzee.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/games/oyatzee/oyatzee.h | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/noncore/games/oyatzee/oyatzee.h b/noncore/games/oyatzee/oyatzee.h index 65a18fc..dd996ee 100644 --- a/noncore/games/oyatzee/oyatzee.h +++ b/noncore/games/oyatzee/oyatzee.h | |||
@@ -1,116 +1,172 @@ | |||
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 | 7 | ||
8 | #include <stdlib.h> // rand() function | 8 | #include <stdlib.h> // rand() function |
9 | #include <qdatetime.h> // seed for rand() | 9 | #include <qdatetime.h> // seed for rand() |
10 | 10 | ||
11 | class Dice; | 11 | class Dice; |
12 | class Game; | 12 | class Game; |
13 | class Scoreboard; | 13 | class Scoreboard; |
14 | class DiceWidget; | 14 | class DiceWidget; |
15 | class Resultboard; | ||
16 | class Player; | ||
15 | 17 | ||
16 | typedef QList<Dice> dicesList; | 18 | typedef QList<Dice> dicesList; |
19 | typedef QList<Resultboard> resultboardList; | ||
17 | typedef QValueList<int> QValueListInt; | 20 | typedef QValueList<int> QValueListInt; |
21 | typedef QList<Player> playerList; | ||
18 | 22 | ||
19 | class OYatzee : public QMainWindow { | 23 | class OYatzee : public QMainWindow { |
20 | Q_OBJECT | 24 | Q_OBJECT |
21 | public: | 25 | public: |
22 | OYatzee( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 26 | OYatzee( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
23 | ~OYatzee(); | 27 | ~OYatzee(); |
24 | 28 | ||
25 | Game *g; | 29 | Game *g; |
26 | DiceWidget *dw; | 30 | DiceWidget *dw; |
27 | Scoreboard *sb; | 31 | Scoreboard *sb; |
28 | 32 | ||
29 | QValueListInt posibilities; | 33 | QValueListInt posibilities; |
30 | 34 | ||
31 | void setPlayerNumber( const int num ); | 35 | void setPlayerNumber( const int num ); |
32 | void setRoundsNumber( const int num ); | 36 | void setRoundsNumber( const int num ); |
33 | 37 | ||
34 | enum { | 38 | enum { |
35 | Ones=1, | 39 | Ones=1, |
36 | Twos = 2, | 40 | Twos = 2, |
37 | Threes = 3, | 41 | Threes = 3, |
38 | Fours = 4, | 42 | Fours = 4, |
39 | Fives = 5, | 43 | Fives = 5, |
40 | Sixes = 6, | 44 | Sixes = 6, |
41 | ThreeOfAKind = 7, //12444 | 45 | ThreeOfAKind = 7, //12444 |
42 | FourOfAKind = 8, //14444 | 46 | FourOfAKind = 8, //14444 |
43 | FullHouse = 9, //22555 | 47 | FullHouse = 9, //22555 |
44 | SStraight = 10, //13456 | 48 | SStraight = 10, //13456 |
45 | LStraight = 11, //12345 | 49 | LStraight = 11, //12345 |
46 | Yatzee = 12, //55555 | 50 | Yatzee = 12, //55555 |
47 | Chance = 13}; | 51 | Chance = 13}; |
48 | 52 | ||
49 | public slots: | 53 | public slots: |
50 | void slotStartGame(); | 54 | void slotStartGame(); |
51 | void slotRollDices(); | 55 | void slotRollDices(); |
52 | 56 | ||
53 | private: | 57 | private: |
54 | int numOfPlayers; | 58 | int numOfPlayers; |
55 | int numOfRounds; | 59 | int numOfRounds; |
56 | 60 | ||
61 | /* | ||
62 | * Check what posibilities the player currently has | ||
63 | */ | ||
57 | void detectPosibilities(); | 64 | void detectPosibilities(); |
58 | void displayPossibilites(); | 65 | void displayPossibilites(); |
59 | 66 | ||
60 | }; | 67 | }; |
61 | 68 | ||
62 | class Dice : public QFrame | 69 | class Dice : public QFrame |
63 | { | 70 | { |
64 | Q_OBJECT | 71 | Q_OBJECT |
65 | public: | 72 | public: |
66 | Dice( QWidget* parent = 0, const char* name = 0 ); | 73 | Dice( QWidget* parent = 0, const char* name = 0 ); |
67 | 74 | ||
68 | int Value; | 75 | int Value; |
69 | bool isSelected; | 76 | bool isSelected; |
70 | 77 | ||
71 | int hasValue(); | 78 | int hasValue(); |
72 | void roll(); | 79 | void roll(); |
73 | virtual void mousePressEvent( QMouseEvent* ); | 80 | virtual void mousePressEvent( QMouseEvent* ); |
74 | 81 | ||
75 | private slots: | 82 | private slots: |
76 | void slotSelected(); | 83 | void slotSelected(); |
77 | 84 | ||
78 | signals: | 85 | signals: |
79 | void selected(); | 86 | void selected(); |
80 | 87 | ||
81 | protected: | 88 | protected: |
82 | void paintEvent( QPaintEvent *e ); | 89 | void paintEvent( QPaintEvent *e ); |
83 | void paintNumber( QPainter *p ); | 90 | void paintNumber( QPainter *p ); |
84 | }; | 91 | }; |
85 | 92 | ||
86 | class DiceWidget : public QWidget | 93 | class DiceWidget : public QWidget |
87 | { | 94 | { |
88 | Q_OBJECT | 95 | Q_OBJECT |
89 | public: | 96 | public: |
90 | DiceWidget( QWidget *parent = 0, const char* name = 0 ); | 97 | DiceWidget( QWidget *parent = 0, const char* name = 0 ); |
91 | 98 | ||
92 | QPushButton *rollButton; | 99 | QPushButton *rollButton; |
93 | 100 | ||
94 | dicesList diceList; | 101 | dicesList diceList; |
95 | }; | 102 | }; |
96 | 103 | ||
104 | |||
105 | class Board : public QWidget | ||
106 | { | ||
107 | Q_OBJECT | ||
108 | public: | ||
109 | Board( QWidget *parent = 0, const char* name = 0 ); | ||
110 | |||
111 | protected: | ||
112 | virtual void paintEvent( QPaintEvent *e ); | ||
113 | }; | ||
114 | |||
115 | class Possibilityboard : public Board | ||
116 | { | ||
117 | Q_OBJECT | ||
118 | |||
119 | public: | ||
120 | Possibilityboard( QWidget *parent = 0, const char* name = 0 ); | ||
121 | |||
122 | protected: | ||
123 | virtual void paintEvent( QPaintEvent *e ); | ||
124 | }; | ||
125 | |||
126 | class Resultboard : public Board | ||
127 | { | ||
128 | Q_OBJECT | ||
129 | |||
130 | public: | ||
131 | Resultboard( QString playerName , QWidget *parent = 0, const char* name = 0 ); | ||
132 | QString pName; | ||
133 | |||
134 | protected: | ||
135 | virtual void paintEvent( QPaintEvent *e ); | ||
136 | }; | ||
137 | |||
138 | |||
97 | class Scoreboard : public QWidget | 139 | class Scoreboard : public QWidget |
98 | { | 140 | { |
99 | Q_OBJECT | 141 | Q_OBJECT |
100 | public: | 142 | public: |
101 | Scoreboard( QWidget *parent = 0, const char* name = 0 ); | 143 | Scoreboard( playerList ps, QWidget *parent = 0, const char* name = 0 ); |
144 | |||
145 | Possibilityboard *pb; | ||
146 | resultboardList rbList; | ||
147 | playerList ps_; | ||
148 | |||
149 | void createResultboards(const int); | ||
102 | 150 | ||
103 | protected: | 151 | protected: |
104 | void paintEvent( QPaintEvent *e ); | 152 | void paintEvent( QPaintEvent *e ); |
105 | }; | 153 | }; |
106 | 154 | ||
155 | |||
107 | class Player | 156 | class Player |
108 | { | 157 | { |
109 | public: | 158 | public: |
110 | Player( QString name ); | 159 | Player( QString name ); |
111 | 160 | ||
112 | QString playerName; | 161 | QString playerName; |
113 | int totalPoints; | 162 | int totalPoints; |
114 | }; | 163 | }; |
115 | 164 | ||
165 | class Game | ||
166 | { | ||
167 | public: | ||
168 | Game( playerList pla ); | ||
169 | playerList players; | ||
170 | }; | ||
171 | |||
116 | #endif // WORDGAME_H | 172 | #endif // WORDGAME_H |