summaryrefslogtreecommitdiff
path: root/noncore/games/backgammon/backgammon.h
blob: 40dbaba180396be298cc83a528e59bc925076a20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#ifndef BACKGAMMON_H
#define BACKGAMMON_H

#include "canvasimageitem.h"
#include "definition.h"
//#include "rulesdialog.h"
#include "moveengine.h"

#include <qcanvas.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qwidget.h>


class BackGammonView : public QCanvasView
{
    Q_OBJECT
public:
    BackGammonView(QCanvas* canvas,QWidget* parent);
    ~BackGammonView();
signals:
    void mouse(int,int);
private:
    void contentsMousePressEvent(QMouseEvent* e);
};

class BackGammon : public QWidget
{
    Q_OBJECT
private:
    //GUI
    //is the style not qte ?
    bool non_qte;
    int offset;
    //the "status" bar
    QLineEdit* inputfield;
    //the main drawing area
    QCanvas* area;
    BackGammonView* boardview;
    CanvasImageItem* board;
    CanvasImageItem* table;
    CanvasImageItem** p1;
    CanvasImageItem** p2;
    CanvasImageItem** p1_side;
    CanvasImageItem** p2_side;

    CanvasImageItem** diceA1;
    CanvasImageItem** diceA2;
    CanvasImageItem** diceB1;
    CanvasImageItem** diceB2;
    //CanvasImageItem** oddsDice;
    CanvasImageItem* nomove_marker;
   
    QCanvasRectangle* marker_current;
    QCanvasRectangle* marker_next[4];
    QLabel* message;
    //ENGINE
    MoveEngine* move;
    //the dice values
    int diceA1_value;
    int diceA2_value;
    int diceA3_value;
    int diceA4_value;
    int diceB1_value;
    int diceB2_value;
    int diceB3_value;
    int diceB4_value;

    int player;
    bool dice1_played;
    bool dice2_played;
    bool dice3_played;
    bool dice4_played;
    bool dice_rolled;
    //computer opponent
    bool player1_auto;
    bool player2_auto;

    //the images;
    QString theme_name;
    QString board_name;
    QString piecesA_name;
    QString piecesB_name;
    QString diceA_name;
    QString diceB_name;
    QString odds_name;
    QString table_name;

    //save game
    QString game_name;

    //the rules
    Rules rules;

    //display settings
    Display display;
    //is the game finished ?
    bool gameFinished;

public:
    BackGammon( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
    ~BackGammon();
private slots:
    void newgame();
    void playerselect();
    void loadgame();
    void savegame();
    void deletegame();
    void newtheme();
    void loadtheme();
    void savetheme();
    void themedefault();
    void deletetheme();
    void modify_AI();
    void setrules();
    void displaySettings();
    void mouse(int x,int y);
    void done_dice1();
    void done_dice2();
    void done_dice3();
    void done_dice4();
    void nomove();
    void nomove2();
    void finished(int theplayer);
    void autoroll_dice1();
    void autoroll_dice2();
private:
    void draw();
    void showdice();
    void setplayer();
    void applytheme();
};

#endif //BACKGAMMON_H