summaryrefslogtreecommitdiff
path: root/noncore/games/oyatzee/oyatzee.h
Side-by-side diff
Diffstat (limited to 'noncore/games/oyatzee/oyatzee.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/oyatzee/oyatzee.h98
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
@@ -1,96 +1,116 @@
#ifndef WORDGAME_H
#define WORDGAME_H
#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()
class Dice;
class Game;
class Scoreboard;
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
public:
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
*/
void detectPosibilities();
void displayPossibilites();
+ int getPoints( const int , QValueListInt );
+
+ void startGame();
+ void stopGame();
+
};
class Dice : public QFrame
{
Q_OBJECT
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();
signals:
void selected();
protected:
- void paintEvent( QPaintEvent *e );
+ void paintEvent( QPaintEvent *e );
void paintNumber( QPainter *p );
+ virtual void mousePressEvent( QMouseEvent* );
};
class DiceWidget : public QWidget
{
Q_OBJECT
public:
@@ -98,39 +118,61 @@ class DiceWidget : public QWidget
QPushButton *rollButton;
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
{
Q_OBJECT
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
{
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 );
};
class Scoreboard : public QWidget
@@ -139,14 +181,17 @@ class Scoreboard : public QWidget
public:
Scoreboard( playerList ps, QWidget *parent = 0, const char* name = 0 );
Possibilityboard *pb;
resultboardList rbList;
playerList ps_;
-
+
void createResultboards(const int);
+
+ Resultboard* nextRB(int);
+
protected:
void paintEvent( QPaintEvent *e );
};
@@ -154,21 +199,20 @@ class Player
{
public:
Player( QString name );
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