summaryrefslogtreecommitdiff
authorzecke <zecke>2004-11-14 22:13:19 (UTC)
committer zecke <zecke>2004-11-14 22:13:19 (UTC)
commit639ae2f86e57b77e875bdf933534b652b207f1b6 (patch) (unidiff)
tree338a4aedb3f0dab5708a958a50f1625a53962ecb
parent489818a4ee9b5328e31d184d5a0b43673b69dff2 (diff)
downloadopie-639ae2f86e57b77e875bdf933534b652b207f1b6.zip
opie-639ae2f86e57b77e875bdf933534b652b207f1b6.tar.gz
opie-639ae2f86e57b77e875bdf933534b652b207f1b6.tar.bz2
Make OYatzee quick launchable
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/oyatzee/main.cpp12
-rw-r--r--noncore/games/oyatzee/opie-oyatzee.control2
-rw-r--r--noncore/games/oyatzee/oyatzee.h1
-rw-r--r--noncore/games/oyatzee/oyatzee.pro4
4 files changed, 5 insertions, 14 deletions
diff --git a/noncore/games/oyatzee/main.cpp b/noncore/games/oyatzee/main.cpp
index 1fd51f6..a5c19f0 100644
--- a/noncore/games/oyatzee/main.cpp
+++ b/noncore/games/oyatzee/main.cpp
@@ -1,13 +1,5 @@
1#include "oyatzee.h" 1#include "oyatzee.h"
2 2
3#include <qpe/qpeapplication.h> 3#include <opie2/oapplicationfactory.h>
4 4
5int main( int argc, char ** argv ) 5OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<OYatzee> )
6{
7 QPEApplication a( argc, argv );
8
9 OYatzee mw;
10 a.showMainWidget(&mw);
11
12 return a.exec();
13}
diff --git a/noncore/games/oyatzee/opie-oyatzee.control b/noncore/games/oyatzee/opie-oyatzee.control
index 8249fed..4eb096c 100644
--- a/noncore/games/oyatzee/opie-oyatzee.control
+++ b/noncore/games/oyatzee/opie-oyatzee.control
@@ -1,11 +1,11 @@
1Package: opie-oyatzee 1Package: opie-oyatzee
2Files: bin/oyatzee apps/Games/oyatzee.desktop pics/oyatzee 2Files: plugins/applications/liboyatzee.so* bin/oyatzee apps/Games/oyatzee.desktop pics/oyatzee
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Carsten Niehaus <cniehaus@handhelds.org> 5Maintainer: Carsten Niehaus <cniehaus@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal 7Depends: task-opie-minimal
8Description: Yatzee-like game 8Description: Yatzee-like game
9 A Yatzee game for the Opie environment. 9 A Yatzee game for the Opie environment.
10 Play against the computer or human opponents. 10 Play against the computer or human opponents.
11Version: $QPE_VERSION$EXTRAVERSION 11Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/oyatzee/oyatzee.h b/noncore/games/oyatzee/oyatzee.h
index 048a733..a38182d 100644
--- a/noncore/games/oyatzee/oyatzee.h
+++ b/noncore/games/oyatzee/oyatzee.h
@@ -1,218 +1,219 @@
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> 7#include <qmap.h>
8#include <qsplitter.h> 8#include <qsplitter.h>
9 9
10#include <stdlib.h> // rand() function 10#include <stdlib.h> // rand() function
11#include <qdatetime.h> // seed for rand() 11#include <qdatetime.h> // seed for rand()
12 12
13class Dice; 13class Dice;
14class Game; 14class Game;
15class Scoreboard; 15class Scoreboard;
16class DiceWidget; 16class DiceWidget;
17class Resultboard; 17class Resultboard;
18class Player; 18class Player;
19 19
20class QPoint; 20class QPoint;
21 21
22typedef QList<Dice> dicesList; 22typedef QList<Dice> dicesList;
23typedef QList<Resultboard> resultboardList; 23typedef QList<Resultboard> resultboardList;
24typedef QValueList<int> QValueListInt; 24typedef QValueList<int> QValueListInt;
25typedef QList<Player> playerList; 25typedef QList<Player> playerList;
26typedef QMap<int,int> pointMap; 26typedef QMap<int,int> pointMap;
27 27
28class OYatzee : public QMainWindow { 28class OYatzee : public QMainWindow {
29 Q_OBJECT 29 Q_OBJECT
30 public: 30 public:
31 OYatzee( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 31 OYatzee( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
32 ~OYatzee(); 32 ~OYatzee();
33 static QString appName() { return QString::fromLatin1("oyatzee"); }
33 34
34 Game *g(); 35 Game *g();
35 DiceWidget *dw; 36 DiceWidget *dw;
36 Scoreboard *sb; 37 Scoreboard *sb;
37 38
38 QValueListInt posibilities; 39 QValueListInt posibilities;
39 playerList ps; 40 playerList ps;
40 41
41 void setPlayerNumber( const int num ); 42 void setPlayerNumber( const int num );
42 void setRoundsNumber( const int num ); 43 void setRoundsNumber( const int num );
43 44
44 enum { Ones = 1, 45 enum { Ones = 1,
45 Twos = 2, 46 Twos = 2,
46 Threes = 3, 47 Threes = 3,
47 Fours = 4, 48 Fours = 4,
48 Fives = 5, 49 Fives = 5,
49 Sixes = 6, 50 Sixes = 6,
50 ThreeOfAKind = 9, //12444 51 ThreeOfAKind = 9, //12444
51 FourOfAKind = 10, //14444 52 FourOfAKind = 10, //14444
52 FullHouse = 11, //22555 53 FullHouse = 11, //22555
53 SStraight = 12, //13456 54 SStraight = 12, //13456
54 LStraight = 13, //12345 55 LStraight = 13, //12345
55 Yatzee = 14, //55555 56 Yatzee = 14, //55555
56 Chance = 15}; 57 Chance = 15};
57 58
58 public slots: 59 public slots:
59 void slotStartGame(); 60 void slotStartGame();
60 void slotRollDices(); 61 void slotRollDices();
61 void slotEndRound( int ); 62 void slotEndRound( int );
62 63
63 private: 64 private:
64 int numOfPlayers; 65 int numOfPlayers;
65 int numOfRounds; 66 int numOfRounds;
66 int currentPlayer; /* the number of the current player */ 67 int currentPlayer; /* the number of the current player */
67 68
68 int oakPoints; 69 int oakPoints;
69 70
70 void nextPlayer(); 71 void nextPlayer();
71 72
72 bool lastPlayerFinished; 73 bool lastPlayerFinished;
73 74
74 /* 75 /*
75 * Check what posibilities the player currently has 76 * Check what posibilities the player currently has
76 */ 77 */
77 void detectPosibilities(); 78 void detectPosibilities();
78 void displayPossibilites(); 79 void displayPossibilites();
79 80
80 int getPoints( const int , QValueListInt ); 81 int getPoints( const int , QValueListInt );
81 82
82 void startGame(); 83 void startGame();
83 void stopGame(); 84 void stopGame();
84 85
85}; 86};
86 87
87class Dice : public QFrame 88class Dice : public QFrame
88{ 89{
89 Q_OBJECT 90 Q_OBJECT
90 public: 91 public:
91 Dice( QWidget* parent = 0, const char* name = 0 ); 92 Dice( QWidget* parent = 0, const char* name = 0 );
92 93
93 bool isSelected; 94 bool isSelected;
94 95
95 const int hasValue() const; 96 const int hasValue() const;
96 void roll(); 97 void roll();
97 98
98 private: 99 private:
99 int Value; 100 int Value;
100 101
101 private slots: 102 private slots:
102 void slotSelected(); 103 void slotSelected();
103 104
104 signals: 105 signals:
105 void selected(); 106 void selected();
106 107
107 protected: 108 protected:
108 void paintEvent( QPaintEvent *e ); 109 void paintEvent( QPaintEvent *e );
109 void paintNumber( QPainter *p ); 110 void paintNumber( QPainter *p );
110 virtual void mousePressEvent( QMouseEvent* ); 111 virtual void mousePressEvent( QMouseEvent* );
111}; 112};
112 113
113class DiceWidget : public QWidget 114class DiceWidget : public QWidget
114{ 115{
115 Q_OBJECT 116 Q_OBJECT
116 public: 117 public:
117 DiceWidget( QWidget *parent = 0, const char* name = 0 ); 118 DiceWidget( QWidget *parent = 0, const char* name = 0 );
118 119
119 QPushButton *rollButton; 120 QPushButton *rollButton;
120 121
121 dicesList diceList; 122 dicesList diceList;
122}; 123};
123 124
124class Board : public QWidget 125class Board : public QWidget
125{ 126{
126 Q_OBJECT 127 Q_OBJECT
127 public: 128 public:
128 Board( QWidget *parent = 0, const char* name = 0 ); 129 Board( QWidget *parent = 0, const char* name = 0 );
129 130
130 signals: 131 signals:
131 void clicked( QPoint ); 132 void clicked( QPoint );
132 void item( int ); 133 void item( int );
133 134
134 protected: 135 protected:
135 virtual void mousePressEvent( QMouseEvent* ); 136 virtual void mousePressEvent( QMouseEvent* );
136}; 137};
137 138
138class Possibilityboard : public Board 139class Possibilityboard : public Board
139{ 140{
140 Q_OBJECT 141 Q_OBJECT
141 142
142 public: 143 public:
143 Possibilityboard( QWidget *parent = 0, const char* name = 0 ); 144 Possibilityboard( QWidget *parent = 0, const char* name = 0 );
144 145
145 QValueListInt list; 146 QValueListInt list;
146 void setIntlist( QValueListInt& ); 147 void setIntlist( QValueListInt& );
147 148
148 private: 149 private:
149 QStringList begriffe; 150 QStringList begriffe;
150 151
151 private slots: 152 private slots:
152 /* 153 /*
153 * this slot returns the item the user has selected 154 * this slot returns the item the user has selected
154 */ 155 */
155 virtual void slotClicked(QPoint); 156 virtual void slotClicked(QPoint);
156 157
157 protected: 158 protected:
158 virtual void paintEvent( QPaintEvent *e ); 159 virtual void paintEvent( QPaintEvent *e );
159}; 160};
160 161
161class Resultboard : public Board 162class Resultboard : public Board
162{ 163{
163 Q_OBJECT 164 Q_OBJECT
164 165
165 public: 166 public:
166 Resultboard( QString playerName = 0 , QWidget *parent = 0, const char* name = 0 ); 167 Resultboard( QString playerName = 0 , QWidget *parent = 0, const char* name = 0 );
167 QString pName; 168 QString pName;
168 169
169 pointMap pMap; 170 pointMap pMap;
170 171
171 void updateMap( int, int ); 172 void updateMap( int, int );
172 173
173 protected: 174 protected:
174 virtual void paintEvent( QPaintEvent *e ); 175 virtual void paintEvent( QPaintEvent *e );
175}; 176};
176 177
177 178
178class Scoreboard : public QWidget 179class Scoreboard : public QWidget
179{ 180{
180 Q_OBJECT 181 Q_OBJECT
181 public: 182 public:
182 Scoreboard( playerList ps, QWidget *parent = 0, const char* name = 0 ); 183 Scoreboard( playerList ps, QWidget *parent = 0, const char* name = 0 );
183 184
184 Possibilityboard *pb; 185 Possibilityboard *pb;
185 resultboardList rbList; 186 resultboardList rbList;
186 playerList ps_; 187 playerList ps_;
187 188
188 void createResultboards(const int); 189 void createResultboards(const int);
189 190
190 Resultboard* nextRB(int); 191 Resultboard* nextRB(int);
191 192
192 193
193 protected: 194 protected:
194 void paintEvent( QPaintEvent *e ); 195 void paintEvent( QPaintEvent *e );
195}; 196};
196 197
197 198
198class Player 199class Player
199{ 200{
200 public: 201 public:
201 Player( QString name ); 202 Player( QString name );
202 203
203 QString playerName; 204 QString playerName;
204 int totalPoints; 205 int totalPoints;
205 206
206 void setResults( const int , const int ); 207 void setResults( const int , const int );
207 208
208 int turn; 209 int turn;
209 210
210 void updateTotalPoints( QMap<int,int> ); 211 void updateTotalPoints( QMap<int,int> );
211 212
212 private: 213 private:
213 QValueListInt pResults; /* the individual results of the player */ 214 QValueListInt pResults; /* the individual results of the player */
214 215
215 void setupResultList(); /* only in the ctor */ 216 void setupResultList(); /* only in the ctor */
216}; 217};
217 218
218#endif // WORDGAME_H 219#endif // WORDGAME_H
diff --git a/noncore/games/oyatzee/oyatzee.pro b/noncore/games/oyatzee/oyatzee.pro
index f505c66..208535a 100644
--- a/noncore/games/oyatzee/oyatzee.pro
+++ b/noncore/games/oyatzee/oyatzee.pro
@@ -1,11 +1,9 @@
1 TEMPLATE= app 1 CONFIG = qt quick-app
2 CONFIG = qt warn_on
3 DESTDIR = $(OPIEDIR)/bin
4 HEADERS = oyatzee.h 2 HEADERS = oyatzee.h
5 SOURCES = main.cpp oyatzee.cpp 3 SOURCES = main.cpp oyatzee.cpp
6 TARGET = oyatzee 4 TARGET = oyatzee
7INCLUDEPATH += $(OPIEDIR)/include 5INCLUDEPATH += $(OPIEDIR)/include
8 DEPENDPATH+= $(OPIEDIR)/include 6 DEPENDPATH+= $(OPIEDIR)/include
9LIBS += -lqpe -lopiecore2 7LIBS += -lqpe -lopiecore2
10 8
11include ( $(OPIEDIR)/include.pro ) 9include ( $(OPIEDIR)/include.pro )