summaryrefslogtreecommitdiff
path: root/noncore/games/backgammon/backgammon.cpp
Unidiff
Diffstat (limited to 'noncore/games/backgammon/backgammon.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/backgammon/backgammon.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/noncore/games/backgammon/backgammon.cpp b/noncore/games/backgammon/backgammon.cpp
index bdb1c78..c286a36 100644
--- a/noncore/games/backgammon/backgammon.cpp
+++ b/noncore/games/backgammon/backgammon.cpp
@@ -1,704 +1,704 @@
1#include "backgammon.h" 1#include "backgammon.h"
2#include "aidialog.h" 2#include "aidialog.h"
3#include "filedialog.h" 3#include "filedialog.h"
4#include "playerdialog.h" 4#include "playerdialog.h"
5#include "rulesdialog.h" 5#include "rulesdialog.h"
6#include "themedialog.h" 6#include "themedialog.h"
7 7
8/* OPIE */ 8/* OPIE */
9#include <opie2/odebug.h> 9#include <opie2/odebug.h>
10#include <qpe/qpeapplication.h> 10#include <qpe/qpeapplication.h>
11#include <qpe/config.h> 11#include <qpe/config.h>
12#include <qpe/resource.h> 12#include <qpe/resource.h>
13using namespace Opie::Core; 13using namespace Opie::Core;
14 14
15/* QT */ 15/* QT */
16#include <qfile.h> 16#include <qfile.h>
17#include <qlayout.h> 17#include <qlayout.h>
18#include <qmessagebox.h> 18#include <qmessagebox.h>
19#include <qtimer.h> 19#include <qtimer.h>
20#include <qmenubar.h> 20#include <qmenubar.h>
21 21
22#include <stdlib.h> 22#include <stdlib.h>
23 23
24 24
25BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) 25BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl)
26 : QMainWindow(parent, name, fl) 26 : QMainWindow(parent, name, fl)
27{ 27{
28 if (!name) setName("BackGammon"); 28 if (!name) setName("BackGammon");
29 setCaption(tr( "Backgammon") ); 29 setCaption(tr( "Backgammon") );
30 setIcon( Resource::loadPixmap( "backgammon" ) ); 30 setIcon( Resource::loadPixmap( "backgammon" ) );
31 //general counter varaible 31 //general counter varaible
32 int a=0; 32 int a=0;
33 //the game engine 33 //the game engine
34 move=new MoveEngine(); 34 move=new MoveEngine();
35 35
36 //load the default theme 36 //load the default theme
37 Config conf("backgammon"); 37 Config conf("backgammon");
38 if(!conf.isValid()) 38 if(!conf.isValid())
39 { 39 {
40 odebug << "config file does not exist" << oendl; 40 odebug << "config file does not exist" << oendl;
41 conf.setGroup("general"); 41 conf.setGroup("general");
42 conf.writeEntry("theme","default"); 42 conf.writeEntry("theme","default");
43 conf.setGroup("rules"); 43 conf.setGroup("rules");
44 conf.writeEntry("move_with_pieces_out",false); 44 conf.writeEntry("move_with_pieces_out",false);
45 conf.writeEntry("nice_dice",false); 45 conf.writeEntry("nice_dice",false);
46 conf.setGroup("display"); 46 conf.setGroup("display");
47 conf.writeEntry("small",false); 47 conf.writeEntry("small",false);
48 conf.writeEntry("warning",true); 48 conf.writeEntry("warning",true);
49 conf.setGroup("ai"); 49 conf.setGroup("ai");
50 conf.writeEntry("rescue",6); 50 conf.writeEntry("rescue",6);
51 conf.writeEntry("eliminate",4); 51 conf.writeEntry("eliminate",4);
52 conf.writeEntry("expose",1); 52 conf.writeEntry("expose",1);
53 conf.writeEntry("protect",5); 53 conf.writeEntry("protect",5);
54 conf.writeEntry("safe",3); 54 conf.writeEntry("safe",3);
55 conf.writeEntry("empty",2); 55 conf.writeEntry("empty",2);
56 56
57 } 57 }
58 conf.setGroup("general"); 58 conf.setGroup("general");
59 theme_name=conf.readEntry("theme","default"); 59 theme_name=conf.readEntry("theme","default");
60 QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; 60 QString theme_file=QPEApplication::qpeDir()+"backgammon/"+theme_name+".theme";
61 61
62 //the rules 62 //the rules
63 conf.setGroup("rules"); 63 conf.setGroup("rules");
64 rules.move_with_pieces_out=conf.readBoolEntry("move_with_pieces_out",false); 64 rules.move_with_pieces_out=conf.readBoolEntry("move_with_pieces_out",false);
65 rules.generous_dice=conf.readBoolEntry("nice_dice",false); 65 rules.generous_dice=conf.readBoolEntry("nice_dice",false);
66 66
67 move->setRules(rules); 67 move->setRules(rules);
68 68
69 //get the AI settings 69 //get the AI settings
70 AISettings ai; 70 AISettings ai;
71 conf.setGroup("ai"); 71 conf.setGroup("ai");
72 ai.rescue=conf.readNumEntry("rescue",6); 72 ai.rescue=conf.readNumEntry("rescue",6);
73 ai.eliminate=conf.readNumEntry("eliminate",4); 73 ai.eliminate=conf.readNumEntry("eliminate",4);
74 ai.expose=conf.readNumEntry("expose",1); 74 ai.expose=conf.readNumEntry("expose",1);
75 ai.protect=conf.readNumEntry("protect",5); 75 ai.protect=conf.readNumEntry("protect",5);
76 ai.safe=conf.readNumEntry("safe",3); 76 ai.safe=conf.readNumEntry("safe",3);
77 ai.empty=conf.readNumEntry("empty",2); 77 ai.empty=conf.readNumEntry("empty",2);
78 move->setAISettings(ai); 78 move->setAISettings(ai);
79 79
80 80
81 //get the theme component names 81 //get the theme component names
82 Config theme(theme_file,Config::File); 82 Config theme(theme_file,Config::File);
83 if(!theme.isValid()) 83 if(!theme.isValid())
84 { 84 {
85 odebug << "theme file does not exist" << oendl; 85 odebug << "theme file does not exist" << oendl;
86 theme.setGroup("theme"); 86 theme.setGroup("theme");
87 theme.writeEntry("board","casino_board_1"); 87 theme.writeEntry("board","casino_board_1");
88 theme.writeEntry("pieces1","casino_pieces_blue"); 88 theme.writeEntry("pieces1","casino_pieces_blue");
89 theme.writeEntry("pieces2","casino_pieces_white"); 89 theme.writeEntry("pieces2","casino_pieces_white");
90 theme.writeEntry("dice1","casino_dice"); 90 theme.writeEntry("dice1","casino_dice");
91 theme.writeEntry("dice2","casino_dice"); 91 theme.writeEntry("dice2","casino_dice");
92 theme.writeEntry("table","casino_table_green"); 92 theme.writeEntry("table","casino_table_green");
93 theme.writeEntry("odds","casino_odds"); 93 theme.writeEntry("odds","casino_odds");
94 } 94 }
95 theme.setGroup("theme"); 95 theme.setGroup("theme");
96 board_name=theme.readEntry("board","casino_board_1"); 96 board_name=theme.readEntry("board","casino_board_1");
97 piecesA_name=theme.readEntry("pieces1","casino_pieces_blue"); 97 piecesA_name=theme.readEntry("pieces1","casino_pieces_blue");
98 piecesB_name=theme.readEntry("pieces2","casino_pieces_white"); 98 piecesB_name=theme.readEntry("pieces2","casino_pieces_white");
99 diceA_name=theme.readEntry("dice1","casino_dice"); 99 diceA_name=theme.readEntry("dice1","casino_dice");
100 diceB_name=theme.readEntry("dice2","casino_dice"); 100 diceB_name=theme.readEntry("dice2","casino_dice");
101 table_name=theme.readEntry("table","casino_table_green"); 101 table_name=theme.readEntry("table","casino_table_green");
102 odds_name=theme.readEntry("odds","casino_odds"); 102 odds_name=theme.readEntry("odds","casino_odds");
103 103
104 104
105 //the menu 105 //the menu
106 QMenuBar* menuBar = new QMenuBar(this); 106 QMenuBar* menuBar = new QMenuBar(this);
107 107
108 QPopupMenu* gamemenu= new QPopupMenu(this); 108 QPopupMenu* gamemenu= new QPopupMenu(this);
109 gamemenu->insertItem(tr( "New" ),this,SLOT(newgame())); 109 gamemenu->insertItem(tr( "New" ),this,SLOT(newgame()));
110 gamemenu->insertSeparator(); 110 gamemenu->insertSeparator();
111 gamemenu->insertItem(tr( "Load" ),this,SLOT(loadgame())); 111 gamemenu->insertItem(tr( "Load" ),this,SLOT(loadgame()));
112 gamemenu->insertItem(tr( "Save" ),this,SLOT(savegame())); 112 gamemenu->insertItem(tr( "Save" ),this,SLOT(savegame()));
113 gamemenu->insertSeparator(); 113 gamemenu->insertSeparator();
114 gamemenu->insertItem(tr( "Delete" ),this,SLOT(deletegame())); 114 gamemenu->insertItem(tr( "Delete" ),this,SLOT(deletegame()));
115 menuBar->insertItem(tr( "Game" ),gamemenu); 115 menuBar->insertItem(tr( "Game" ),gamemenu);
116 116
117 QPopupMenu* thememenu= new QPopupMenu(this); 117 QPopupMenu* thememenu= new QPopupMenu(this);
118 thememenu->insertItem(tr( "New" ),this,SLOT(newtheme())); 118 thememenu->insertItem(tr( "New" ),this,SLOT(newtheme()));
119 thememenu->insertSeparator(); 119 thememenu->insertSeparator();
120 thememenu->insertItem(tr( "Load"),this,SLOT(loadtheme())); 120 thememenu->insertItem(tr( "Load"),this,SLOT(loadtheme()));
121 thememenu->insertItem(tr( "Save" ),this,SLOT(savetheme())); 121 thememenu->insertItem(tr( "Save" ),this,SLOT(savetheme()));
122 thememenu->insertSeparator(); 122 thememenu->insertSeparator();
123 thememenu->insertItem(tr( "Default"),this,SLOT(themedefault())); 123 thememenu->insertItem(tr( "Default"),this,SLOT(themedefault()));
124 thememenu->insertItem(tr( "Delete" ),this,SLOT(deletetheme())); 124 thememenu->insertItem(tr( "Delete" ),this,SLOT(deletetheme()));
125 menuBar->insertItem(tr( "Theme" ),thememenu); 125 menuBar->insertItem(tr( "Theme" ),thememenu);
126 126
127 QPopupMenu* optionmenu=new QPopupMenu(this); 127 QPopupMenu* optionmenu=new QPopupMenu(this);
128 optionmenu->insertItem(tr( "Player" ),this,SLOT(playerselect())); 128 optionmenu->insertItem(tr( "Player" ),this,SLOT(playerselect()));
129 optionmenu->insertSeparator(); 129 optionmenu->insertSeparator();
130 optionmenu->insertItem(tr( "AI" ),this,SLOT(modify_AI())); 130 optionmenu->insertItem(tr( "AI" ),this,SLOT(modify_AI()));
131 optionmenu->insertItem(tr( "Rules" ),this,SLOT(setrules())); 131 optionmenu->insertItem(tr( "Rules" ),this,SLOT(setrules()));
132 menuBar->insertItem(tr( "Options"),optionmenu); 132 menuBar->insertItem(tr( "Options"),optionmenu);
133 133
134 QWidget* mainarea=new QWidget(this); 134 QWidget* mainarea=new QWidget(this);
135 setCentralWidget(mainarea); 135 setCentralWidget(mainarea);
136 //the main area 136 //the main area
137 QBoxLayout* layout=new QBoxLayout(mainarea,QBoxLayout::TopToBottom); 137 QBoxLayout* layout=new QBoxLayout(mainarea,QBoxLayout::TopToBottom);
138 area=new QCanvas(235,235); 138 area=new QCanvas(235,235);
139 boardview=new BackGammonView(area,mainarea); 139 boardview=new BackGammonView(area,mainarea);
140 boardview->setMaximumHeight(240); 140 boardview->setMaximumHeight(240);
141 layout->addWidget(boardview); 141 layout->addWidget(boardview);
142 connect(boardview,SIGNAL(mouse(int,int)),this,SLOT(mouse(int,int))); 142 connect(boardview,SIGNAL(mouse(int,int)),this,SLOT(mouse(int,int)));
143 //status bar 143 //status bar
144 message=new QLabel("<b>Backgammon</b>",mainarea); 144 message=new QLabel("<b>Backgammon</b>",mainarea);
145 message->setAlignment(AlignHCenter); 145 message->setAlignment(AlignHCenter);
146 layout->addWidget(message); 146 layout->addWidget(message);
147 147
148 //the marker 148 //the marker
149 marker_current=new QCanvasRectangle(area); 149 marker_current=new QCanvasRectangle(area);
150 marker_current->setBrush(QColor(0,0,255)); 150 marker_current->setBrush(QColor(0,0,255));
151 marker_current->setSize(15,5); 151 marker_current->setSize(15,5);
152 marker_current->setZ(1); 152 marker_current->setZ(1);
153 153
154 for(a=0;a<4;a++) 154 for(a=0;a<4;a++)
155 { 155 {
156 marker_next[a]=new QCanvasRectangle(area); 156 marker_next[a]=new QCanvasRectangle(area);
157 marker_next[a]->setBrush(QColor(0,255,0)); 157 marker_next[a]->setBrush(QColor(0,255,0));
158 marker_next[a]->setSize(15,5); 158 marker_next[a]->setSize(15,5);
159 marker_next[a]->setZ(1); 159 marker_next[a]->setZ(1);
160 } 160 }
161 161
162 connect(move,SIGNAL(done_dice1()),this,SLOT(done_dice1())); 162 connect(move,SIGNAL(done_dice1()),this,SLOT(done_dice1()));
163 connect(move,SIGNAL(done_dice2()),this,SLOT(done_dice2())); 163 connect(move,SIGNAL(done_dice2()),this,SLOT(done_dice2()));
164 connect(move,SIGNAL(done_dice3()),this,SLOT(done_dice3())); 164 connect(move,SIGNAL(done_dice3()),this,SLOT(done_dice3()));
165 connect(move,SIGNAL(done_dice4()),this,SLOT(done_dice4())); 165 connect(move,SIGNAL(done_dice4()),this,SLOT(done_dice4()));
166 connect(move,SIGNAL(nomove()),this,SLOT(nomove())); 166 connect(move,SIGNAL(nomove()),this,SLOT(nomove()));
167 connect(move,SIGNAL(player_finished(int)),this,SLOT(finished(int))); 167 connect(move,SIGNAL(player_finished(int)),this,SLOT(finished(int)));
168 168
169 //the pieces 169 //the pieces
170 p1=new CanvasImageItem*[15]; 170 p1=new CanvasImageItem*[15];
171 p1_side=new CanvasImageItem*[15]; 171 p1_side=new CanvasImageItem*[15];
172 QImage piece_1_all(Resource::loadImage("backgammon/pieces/"+piecesA_name)); 172 QImage piece_1_all(Resource::loadImage("backgammon/pieces/"+piecesA_name));
173 QImage piece_1_front=piece_1_all.copy(0,0,15,15); 173 QImage piece_1_front=piece_1_all.copy(0,0,15,15);
174 QImage piece_1_side=piece_1_all.copy(0,15,15,5); 174 QImage piece_1_side=piece_1_all.copy(0,15,15,5);
175 175
176 p2=new CanvasImageItem*[15]; 176 p2=new CanvasImageItem*[15];
177 p2_side=new CanvasImageItem*[15]; 177 p2_side=new CanvasImageItem*[15];
178 QImage piece_2_all(Resource::loadImage("backgammon/pieces/"+piecesB_name)); 178 QImage piece_2_all(Resource::loadImage("backgammon/pieces/"+piecesB_name));
179 QImage piece_2_front=piece_2_all.copy(0,0,15,15); 179 QImage piece_2_front=piece_2_all.copy(0,0,15,15);
180 QImage piece_2_side=piece_2_all.copy(0,15,15,5); 180 QImage piece_2_side=piece_2_all.copy(0,15,15,5);
181 181
182 182
183 for(a=0;a<15;a++) 183 for(a=0;a<15;a++)
184 { 184 {
185 p1[a]=new CanvasImageItem(piece_1_front,area); 185 p1[a]=new CanvasImageItem(piece_1_front,area);
186 p1[a]->setSize(15,15); 186 p1[a]->setSize(15,15);
187 p1_side[a]=new CanvasImageItem(piece_1_side,area); 187 p1_side[a]=new CanvasImageItem(piece_1_side,area);
188 p1_side[a]->setSize(15,5); 188 p1_side[a]->setSize(15,5);
189 189
190 p2[a]=new CanvasImageItem(piece_2_front,area); 190 p2[a]=new CanvasImageItem(piece_2_front,area);
191 p2[a]->setSize(15,15); 191 p2[a]->setSize(15,15);
192 p2_side[a]=new CanvasImageItem(piece_2_side,area); 192 p2_side[a]=new CanvasImageItem(piece_2_side,area);
193 p2_side[a]->setSize(15,5); 193 p2_side[a]->setSize(15,5);
194 } 194 }
195 draw(); 195 draw();
196 196
197 //the dice 197 //the dice
198 QImage dicebgA_all(Resource::loadImage("backgammon/dice/"+diceA_name)); 198 QImage dicebgA_all(Resource::loadImage("backgammon/dice/"+diceA_name));
199 diceA1=new CanvasImageItem*[7]; 199 diceA1=new CanvasImageItem*[7];
200 diceA2=new CanvasImageItem*[7]; 200 diceA2=new CanvasImageItem*[7];
201 QImage dicebgB_all(Resource::loadImage("backgammon/dice/"+diceB_name)); 201 QImage dicebgB_all(Resource::loadImage("backgammon/dice/"+diceB_name));
202 diceB1=new CanvasImageItem*[7]; 202 diceB1=new CanvasImageItem*[7];
203 diceB2=new CanvasImageItem*[7]; 203 diceB2=new CanvasImageItem*[7];
204 QImage oddsbg_all=(Resource::loadImage("backgammon/odds/"+odds_name)); 204 QImage oddsbg_all=(Resource::loadImage("backgammon/odds/"+odds_name));
205 //oddsDice=new CanvasImageItem*[6]; 205 //oddsDice=new CanvasImageItem*[6];
206 206
207 207
208 for(a=0;a<7;a++) 208 for(a=0;a<7;a++)
209 { 209 {
210 QImage dicebgA=dicebgA_all.copy(a*25,0,25,25); 210 QImage dicebgA=dicebgA_all.copy(a*25,0,25,25);
211 diceA1[a]=new CanvasImageItem(dicebgA,area); 211 diceA1[a]=new CanvasImageItem(dicebgA,area);
212 diceA1[a]->setX(5); 212 diceA1[a]->setX(5);
213 diceA1[a]->setY(205-2); 213 diceA1[a]->setY(205-2);
214 diceA1[a]->setZ(1); 214 diceA1[a]->setZ(1);
215 diceA1[a]->setSize(25,25); 215 diceA1[a]->setSize(25,25);
216 diceA2[a]=new CanvasImageItem(dicebgA,area); 216 diceA2[a]=new CanvasImageItem(dicebgA,area);
217 diceA2[a]->setX(35); 217 diceA2[a]->setX(35);
218 diceA2[a]->setY(205-2); 218 diceA2[a]->setY(205-2);
219 diceA2[a]->setZ(1); 219 diceA2[a]->setZ(1);
220 diceA2[a]->setSize(25,25); 220 diceA2[a]->setSize(25,25);
221 221
222 QImage dicebgB=dicebgB_all.copy(a*25,0,25,25); 222 QImage dicebgB=dicebgB_all.copy(a*25,0,25,25);
223 diceB1[a]=new CanvasImageItem(dicebgB,area); 223 diceB1[a]=new CanvasImageItem(dicebgB,area);
224 diceB1[a]->setX(175); 224 diceB1[a]->setX(175);
225 diceB1[a]->setY(205-2); 225 diceB1[a]->setY(205-2);
226 diceB1[a]->setZ(1); 226 diceB1[a]->setZ(1);
227 diceB1[a]->setSize(25,25); 227 diceB1[a]->setSize(25,25);
228 diceB2[a]=new CanvasImageItem(dicebgB,area); 228 diceB2[a]=new CanvasImageItem(dicebgB,area);
229 diceB2[a]->setX(205); 229 diceB2[a]->setX(205);
230 diceB2[a]->setY(205-2); 230 diceB2[a]->setY(205-2);
231 diceB2[a]->setZ(1); 231 diceB2[a]->setZ(1);
232 diceB2[a]->setSize(25,25); 232 diceB2[a]->setSize(25,25);
233 233
234 /* 234 /*
235 if(a<6) 235 if(a<6)
236 { 236 {
237 QImage oddsbg=oddsbg_all.copy(a*15,0,15,15); 237 QImage oddsbg=oddsbg_all.copy(a*15,0,15,15);
238 oddsDice[a]=new CanvasImageItem(oddsbg,area); 238 oddsDice[a]=new CanvasImageItem(oddsbg,area);
239 oddsDice[a]->setX(110); 239 oddsDice[a]->setX(110);
240 oddsDice[a]->setY(210-2); 240 oddsDice[a]->setY(210-2);
241 oddsDice[a]->setZ(1); 241 oddsDice[a]->setZ(1);
242 oddsDice[a]->setSize(15,15); 242 oddsDice[a]->setSize(15,15);
243 oddsDice[a]->hide(); 243 oddsDice[a]->hide();
244 } 244 }
245 */ 245 */
246 } 246 }
247 //oddsDice[0]->show(); 247 //oddsDice[0]->show();
248 248
249 //set the board 249 //set the board
250 QImage boardbg(Resource::loadImage("backgammon/boards/"+board_name)); 250 QImage boardbg(Resource::loadImage("backgammon/boards/"+board_name));
251 board=new CanvasImageItem(boardbg,area); 251 board=new CanvasImageItem(boardbg,area);
252 board->setX(0); 252 board->setX(0);
253 board->setY(0); 253 board->setY(0);
254 board->setZ(0); 254 board->setZ(0);
255 board->setSize(235-2,200-2); 255 board->setSize(235-2,200-2);
256 board->show(); 256 board->show();
257 257
258 //the table 258 //the table
259 QImage tablebg(Resource::loadImage("backgammon/table/"+table_name)); 259 QImage tablebg(Resource::loadImage("backgammon/table/"+table_name));
260 table=new CanvasImageItem(tablebg,area); 260 table=new CanvasImageItem(tablebg,area);
261 table->setX(0); 261 table->setX(0);
262 table->setY(200-2); 262 table->setY(200-2);
263 table->setZ(0); 263 table->setZ(0);
264 table->setSize(235-2,20); 264 table->setSize(235-2,20);
265 table->show(); 265 table->show();
266 266
267 //the no move marker 267 //the no move marker
268 QImage nomovebg(Resource::loadImage("backgammon/no_move")); 268 QImage nomovebg(Resource::loadImage("backgammon/no_move"));
269 nomove_marker=new CanvasImageItem(nomovebg,area); 269 nomove_marker=new CanvasImageItem(nomovebg,area);
270 nomove_marker->setX(0); 270 nomove_marker->setX(0);
271 nomove_marker->setY(200); 271 nomove_marker->setY(200);
272 nomove_marker->setZ(2); 272 nomove_marker->setZ(2);
273 nomove_marker->hide(); 273 nomove_marker->hide();
274 274
275 //default human against computer 275 //default human against computer
276 player1_auto=false; 276 player1_auto=false;
277 player2_auto=true; 277 player2_auto=true;
278 //start new game 278 //start new game
279 newgame(); 279 newgame();
280} 280}
281 281
282BackGammon::~BackGammon() 282BackGammon::~BackGammon()
283{ 283{
284 //DESTRUCTOR 284 //DESTRUCTOR
285} 285}
286 286
287void BackGammon::newgame() 287void BackGammon::newgame()
288{ 288{
289 gameFinished=false; 289 gameFinished=false;
290 QDateTime now=QDateTime::currentDateTime(); 290 QDateTime now=QDateTime::currentDateTime();
291 game_name=now.date().toString()+"_"+now.time().toString(); 291 game_name=now.date().toString()+"_"+now.time().toString();
292 move->reset(); 292 move->reset();
293 draw(); 293 draw();
294 diceA1_value=7; 294 diceA1_value=7;
295 diceA2_value=7; 295 diceA2_value=7;
296 diceA3_value=7; 296 diceA3_value=7;
297 diceA4_value=7; 297 diceA4_value=7;
298 diceB1_value=7; 298 diceB1_value=7;
299 diceB2_value=7; 299 diceB2_value=7;
300 diceB3_value=7; 300 diceB3_value=7;
301 diceB4_value=7; 301 diceB4_value=7;
302 showdice(); 302 showdice();
303 player=2; 303 player=2;
304 dice1_played=true; 304 dice1_played=true;
305 dice2_played=true; 305 dice2_played=true;
306 dice3_played=true; 306 dice3_played=true;
307 dice4_played=true; 307 dice4_played=true;
308 dice_rolled=false; 308 dice_rolled=false;
309 setplayer(); 309 setplayer();
310 area->update(); 310 area->update();
311} 311}
312 312
313void BackGammon::playerselect() 313void BackGammon::playerselect()
314{ 314{
315 PlayerDialog* playerdialog=new PlayerDialog(this); 315 PlayerDialog* playerdialog=new PlayerDialog(this);
316 playerdialog->setAuto1(player1_auto); 316 playerdialog->setAuto1(player1_auto);
317 playerdialog->setAuto2(player2_auto); 317 playerdialog->setAuto2(player2_auto);
318 if(!playerdialog->exec()) 318 if(!playerdialog->exec())
319 return; 319 return;
320 player1_auto=playerdialog->getAuto1(); 320 player1_auto=playerdialog->getAuto1();
321 player2_auto=playerdialog->getAuto2(); 321 player2_auto=playerdialog->getAuto2();
322} 322}
323 323
324void BackGammon::loadgame() 324void BackGammon::loadgame()
325{ 325{
326 FileDialog* file=new FileDialog(this,"Load Game",".game"); 326 FileDialog* file=new FileDialog(this,"Load Game",".game");
327 if(!file->exec()) 327 if(!file->exec())
328 return; 328 return;
329 329
330 game_name=file->filename(); 330 game_name=file->filename();
331 QString game_file=QPEApplication::qpeDir()+"/backgammon/"+game_name+".game"; 331 QString game_file=QPEApplication::qpeDir()+"backgammon/"+game_name+".game";
332 332
333 Config game(game_file,Config::File); 333 Config game(game_file,Config::File);
334 game.setGroup("dice"); 334 game.setGroup("dice");
335 diceA1_value=game.readNumEntry("diceA1_value"); 335 diceA1_value=game.readNumEntry("diceA1_value");
336 diceA2_value=game.readNumEntry("diceA2_value"); 336 diceA2_value=game.readNumEntry("diceA2_value");
337 diceA3_value=game.readNumEntry("diceA3_value"); 337 diceA3_value=game.readNumEntry("diceA3_value");
338 diceA4_value=game.readNumEntry("diceA4_value"); 338 diceA4_value=game.readNumEntry("diceA4_value");
339 diceB1_value=game.readNumEntry("diceB1_value"); 339 diceB1_value=game.readNumEntry("diceB1_value");
340 diceB2_value=game.readNumEntry("diceB2_value"); 340 diceB2_value=game.readNumEntry("diceB2_value");
341 diceB3_value=game.readNumEntry("diceB3_value"); 341 diceB3_value=game.readNumEntry("diceB3_value");
342 diceB4_value=game.readNumEntry("diceB4_value"); 342 diceB4_value=game.readNumEntry("diceB4_value");
343 player=game.readNumEntry("player"); 343 player=game.readNumEntry("player");
344 dice1_played=game.readBoolEntry("dice1_played"); 344 dice1_played=game.readBoolEntry("dice1_played");
345 dice2_played=game.readBoolEntry("dice2_played"); 345 dice2_played=game.readBoolEntry("dice2_played");
346 dice3_played=game.readBoolEntry("dice3_played"); 346 dice3_played=game.readBoolEntry("dice3_played");
347 dice4_played=game.readBoolEntry("dice4_played"); 347 dice4_played=game.readBoolEntry("dice4_played");
348 dice_rolled=game.readBoolEntry("dice_rolled"); 348 dice_rolled=game.readBoolEntry("dice_rolled");
349 player1_auto=game.readBoolEntry("player1_auto"); 349 player1_auto=game.readBoolEntry("player1_auto");
350 player2_auto=game.readBoolEntry("player2_auto"); 350 player2_auto=game.readBoolEntry("player2_auto");
351 351
352 game.setGroup("pieces"); 352 game.setGroup("pieces");
353 QString label; 353 QString label;
354 LoadSave load; 354 LoadSave load;
355 for(int a=0;a<28;a++) 355 for(int a=0;a<28;a++)
356 { 356 {
357 label.setNum(a); 357 label.setNum(a);
358 load.pop[a].total = game.readNumEntry(label,0); 358 load.pop[a].total = game.readNumEntry(label,0);
359 } 359 }
360 360
361 move->loadGame(load); 361 move->loadGame(load);
362 setplayer(); 362 setplayer();
363 showdice(); 363 showdice();
364 draw(); 364 draw();
365 area->update(); 365 area->update();
366} 366}
367 367
368void BackGammon::savegame() 368void BackGammon::savegame()
369{ 369{
370 QString game_file=QPEApplication::qpeDir()+"/backgammon/"+game_name+".game"; 370 QString game_file=QPEApplication::qpeDir()+"backgammon/"+game_name+".game";
371 371
372 Config game(game_file,Config::File); 372 Config game(game_file,Config::File);
373 game.setGroup("dice"); 373 game.setGroup("dice");
374 game.writeEntry("diceA1_value",diceA1_value); 374 game.writeEntry("diceA1_value",diceA1_value);
375 game.writeEntry("diceA2_value",diceA2_value); 375 game.writeEntry("diceA2_value",diceA2_value);
376 game.writeEntry("diceA3_value",diceA3_value); 376 game.writeEntry("diceA3_value",diceA3_value);
377 game.writeEntry("diceA4_value",diceA4_value); 377 game.writeEntry("diceA4_value",diceA4_value);
378 game.writeEntry("diceB1_value",diceB1_value); 378 game.writeEntry("diceB1_value",diceB1_value);
379 game.writeEntry("diceB2_value",diceB3_value); 379 game.writeEntry("diceB2_value",diceB3_value);
380 game.writeEntry("diceB3_value",diceB4_value); 380 game.writeEntry("diceB3_value",diceB4_value);
381 game.writeEntry("diceB4_value",diceB4_value); 381 game.writeEntry("diceB4_value",diceB4_value);
382 game.writeEntry("player",player); 382 game.writeEntry("player",player);
383 game.writeEntry("dice1_played",dice1_played); 383 game.writeEntry("dice1_played",dice1_played);
384 game.writeEntry("dice2_played",dice2_played); 384 game.writeEntry("dice2_played",dice2_played);
385 game.writeEntry("dice3_played",dice3_played); 385 game.writeEntry("dice3_played",dice3_played);
386 game.writeEntry("dice4_played",dice4_played); 386 game.writeEntry("dice4_played",dice4_played);
387 game.writeEntry("dice_rolled",dice_rolled); 387 game.writeEntry("dice_rolled",dice_rolled);
388 game.writeEntry("player1_auto",player1_auto); 388 game.writeEntry("player1_auto",player1_auto);
389 game.writeEntry("player2_auto",player2_auto); 389 game.writeEntry("player2_auto",player2_auto);
390 390
391 game.setGroup("pieces"); 391 game.setGroup("pieces");
392 QString label; 392 QString label;
393 LoadSave save=move->saveGame(); 393 LoadSave save=move->saveGame();
394 for(int a=0;a<28;a++) 394 for(int a=0;a<28;a++)
395 { 395 {
396 label.setNum(a); 396 label.setNum(a);
397 game.writeEntry(label,save.pop[a].total); 397 game.writeEntry(label,save.pop[a].total);
398 } 398 }
399 QMessageBox::information(this,"Backgammon","Game saved","OK"); 399 QMessageBox::information(this,"Backgammon","Game saved","OK");
400} 400}
401 401
402void BackGammon::deletegame() 402void BackGammon::deletegame()
403{ 403{
404 FileDialog* file=new FileDialog(this,"Delete Game",".game"); 404 FileDialog* file=new FileDialog(this,"Delete Game",".game");
405 if(!file->exec()) 405 if(!file->exec())
406 return; 406 return;
407 407
408 game_name=file->filename(); 408 game_name=file->filename();
409 QString game_file=QPEApplication::qpeDir()+"/backgammon/"+game_name+".game"; 409 QString game_file=QPEApplication::qpeDir()+"backgammon/"+game_name+".game";
410 410
411 if(!QMessageBox::warning(this,"Backgammon","deleted game\n"+game_name+" ?","OK","Cancel")) 411 if(!QMessageBox::warning(this,"Backgammon","deleted game\n"+game_name+" ?","OK","Cancel"))
412 { 412 {
413 QFile(game_file).remove(); 413 QFile(game_file).remove();
414 } 414 }
415} 415}
416 416
417 417
418void BackGammon::newtheme() 418void BackGammon::newtheme()
419{ 419{
420 ThemeDialog* theme=new ThemeDialog(this); 420 ThemeDialog* theme=new ThemeDialog(this);
421 421
422 ImageNames names; 422 ImageNames names;
423 names.theme=theme_name; 423 names.theme=theme_name;
424 names.board=board_name; 424 names.board=board_name;
425 names.pieces1=piecesA_name; 425 names.pieces1=piecesA_name;
426 names.pieces2=piecesB_name; 426 names.pieces2=piecesB_name;
427 names.dice1=diceA_name; 427 names.dice1=diceA_name;
428 names.dice2=diceB_name; 428 names.dice2=diceB_name;
429 names.odds=odds_name; 429 names.odds=odds_name;
430 names.table=table_name; 430 names.table=table_name;
431 431
432 theme->setCurrent(names); 432 theme->setCurrent(names);
433 if(!theme->exec()) 433 if(!theme->exec())
434 return; 434 return;
435 435
436 names=theme->getNames(); 436 names=theme->getNames();
437 theme_name=names.theme; 437 theme_name=names.theme;
438 board_name=names.board; 438 board_name=names.board;
439 piecesA_name=names.pieces1; 439 piecesA_name=names.pieces1;
440 piecesB_name=names.pieces2; 440 piecesB_name=names.pieces2;
441 diceA_name=names.dice1; 441 diceA_name=names.dice1;
442 diceB_name=names.dice2; 442 diceB_name=names.dice2;
443 odds_name=names.odds; 443 odds_name=names.odds;
444 table_name=names.table; 444 table_name=names.table;
445 445
446 applytheme(); 446 applytheme();
447} 447}
448 448
449void BackGammon::loadtheme() 449void BackGammon::loadtheme()
450{ 450{
451 FileDialog* file=new FileDialog(this,"Load Theme",".theme"); 451 FileDialog* file=new FileDialog(this,"Load Theme",".theme");
452 if(!file->exec()) 452 if(!file->exec())
453 return; 453 return;
454 454
455 theme_name=file->filename(); 455 theme_name=file->filename();
456 QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; 456 QString theme_file=QPEApplication::qpeDir()+"backgammon/"+theme_name+".theme";
457 457
458 Config theme(theme_file,Config::File); 458 Config theme(theme_file,Config::File);
459 theme.setGroup("theme"); 459 theme.setGroup("theme");
460 board_name=theme.readEntry("board","board_1"); 460 board_name=theme.readEntry("board","board_1");
461 piecesA_name=theme.readEntry("pieces1","pieces_1"); 461 piecesA_name=theme.readEntry("pieces1","pieces_1");
462 piecesB_name=theme.readEntry("pieces2","pieces_2"); 462 piecesB_name=theme.readEntry("pieces2","pieces_2");
463 diceA_name=theme.readEntry("dice1","dice_1"); 463 diceA_name=theme.readEntry("dice1","dice_1");
464 diceB_name=theme.readEntry("dice2","dice_2"); 464 diceB_name=theme.readEntry("dice2","dice_2");
465 table_name=theme.readEntry("table","table_1"); 465 table_name=theme.readEntry("table","table_1");
466 odds_name=theme.readEntry("odds","odds_1"); 466 odds_name=theme.readEntry("odds","odds_1");
467 467
468 applytheme(); 468 applytheme();
469 469
470} 470}
471 471
472void BackGammon::savetheme() 472void BackGammon::savetheme()
473{ 473{
474 if(theme_name=="default") 474 if(theme_name=="default")
475 { 475 {
476 QMessageBox::information(this,"Backgammon","Sorry\nCannot overwrite default.theme","OK"); 476 QMessageBox::information(this,"Backgammon","Sorry\nCannot overwrite default.theme","OK");
477 return; 477 return;
478 } 478 }
479 QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; 479 QString theme_file=QPEApplication::qpeDir()+"backgammon/"+theme_name+".theme";
480 if(QMessageBox::information(this,"Backgammon","Save Theme\n"+theme_name,"Yes","No")) 480 if(QMessageBox::information(this,"Backgammon","Save Theme\n"+theme_name,"Yes","No"))
481 return; 481 return;
482 482
483 Config theme(theme_file,Config::File); 483 Config theme(theme_file,Config::File);
484 theme.setGroup("theme"); 484 theme.setGroup("theme");
485 theme.writeEntry("board",board_name); 485 theme.writeEntry("board",board_name);
486 theme.writeEntry("pieces1",piecesA_name); 486 theme.writeEntry("pieces1",piecesA_name);
487 theme.writeEntry("pieces2",piecesB_name); 487 theme.writeEntry("pieces2",piecesB_name);
488 theme.writeEntry("dice1",diceA_name); 488 theme.writeEntry("dice1",diceA_name);
489 theme.writeEntry("dice2",diceB_name); 489 theme.writeEntry("dice2",diceB_name);
490 theme.writeEntry("table",table_name); 490 theme.writeEntry("table",table_name);
491 theme.writeEntry("odds",odds_name); 491 theme.writeEntry("odds",odds_name);
492 492
493} 493}
494 494
495void BackGammon::themedefault() 495void BackGammon::themedefault()
496{ 496{
497 if(QMessageBox::information(this,"Backgammon","Make Theme\n"+theme_name+"\nthe default theme","Yes","No")) 497 if(QMessageBox::information(this,"Backgammon","Make Theme\n"+theme_name+"\nthe default theme","Yes","No"))
498 return; 498 return;
499 499
500 Config conf("backgammon"); 500 Config conf("backgammon");
501 conf.setGroup("general"); 501 conf.setGroup("general");
502 conf.writeEntry("theme",theme_name); 502 conf.writeEntry("theme",theme_name);
503} 503}
504 504
505void BackGammon::deletetheme() 505void BackGammon::deletetheme()
506{ 506{
507 FileDialog* file=new FileDialog(this,"Delete Theme",".theme"); 507 FileDialog* file=new FileDialog(this,"Delete Theme",".theme");
508 if(!file->exec()) 508 if(!file->exec())
509 return; 509 return;
510 510
511 theme_name=file->filename(); 511 theme_name=file->filename();
512 QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; 512 QString theme_file=QPEApplication::qpeDir()+"backgammon/"+theme_name+".theme";
513 513
514 if(!QMessageBox::warning(this,tr( "Backgammon" ),tr( "deleted theme %1?").arg(theme_name),tr( "OK" ),tr( "Cancel" ))) 514 if(!QMessageBox::warning(this,tr( "Backgammon" ),tr( "deleted theme %1?").arg(theme_name),tr( "OK" ),tr( "Cancel" )))
515 { 515 {
516 QFile(theme_file).remove(); 516 QFile(theme_file).remove();
517 } 517 }
518} 518}
519 519
520void BackGammon::modify_AI() 520void BackGammon::modify_AI()
521{ 521{
522 AI_Dialog* ai_mod=new AI_Dialog(this,tr( "Load Theme" ),".theme"); 522 AI_Dialog* ai_mod=new AI_Dialog(this,tr( "Load Theme" ),".theme");
523 ai_mod->setAISettings(move->getAISettings()); 523 ai_mod->setAISettings(move->getAISettings());
524 if(!ai_mod->exec()) 524 if(!ai_mod->exec())
525 return; 525 return;
526 526
527 //get the AI settings 527 //get the AI settings
528 AISettings ai=ai_mod->getAISettings(); 528 AISettings ai=ai_mod->getAISettings();
529 move->setAISettings(ai); 529 move->setAISettings(ai);
530 //write new settings to conf file 530 //write new settings to conf file
531 Config conf("backgammon"); 531 Config conf("backgammon");
532 conf.setGroup("ai"); 532 conf.setGroup("ai");
533 conf.writeEntry("rescue",ai.rescue); 533 conf.writeEntry("rescue",ai.rescue);
534 conf.writeEntry("eliminate",ai.eliminate); 534 conf.writeEntry("eliminate",ai.eliminate);
535 conf.writeEntry("expose",ai.expose); 535 conf.writeEntry("expose",ai.expose);
536 conf.writeEntry("protect",ai.protect); 536 conf.writeEntry("protect",ai.protect);
537 conf.writeEntry("safe",ai.safe); 537 conf.writeEntry("safe",ai.safe);
538 conf.writeEntry("empty",ai.empty); 538 conf.writeEntry("empty",ai.empty);
539} 539}
540 540
541void BackGammon::setrules() 541void BackGammon::setrules()
542{ 542{
543 RulesDialog* rulesdialog=new RulesDialog(this,tr( "Load Theme" ),".theme"); 543 RulesDialog* rulesdialog=new RulesDialog(this,tr( "Load Theme" ),".theme");
544 rulesdialog->setRules(rules); 544 rulesdialog->setRules(rules);
545 if(!rulesdialog->exec()) 545 if(!rulesdialog->exec())
546 return; 546 return;
547 rules=rulesdialog->getRules(); 547 rules=rulesdialog->getRules();
548 Config conf("backgammon"); 548 Config conf("backgammon");
549 conf.setGroup("rules"); 549 conf.setGroup("rules");
550 conf.writeEntry("move_with_pieces_out",rules.move_with_pieces_out); 550 conf.writeEntry("move_with_pieces_out",rules.move_with_pieces_out);
551 conf.writeEntry("nice_dice",rules.generous_dice); 551 conf.writeEntry("nice_dice",rules.generous_dice);
552 move->setRules(rules); 552 move->setRules(rules);
553} 553}
554 554
555 555
556void BackGammon::draw() 556void BackGammon::draw()
557{ 557{
558 Pieces pieces; 558 Pieces pieces;
559 move->position(pieces); 559 move->position(pieces);
560 for(int a=0;a<15;a++) 560 for(int a=0;a<15;a++)
561 { 561 {
562 if(!pieces.player1[a].side) 562 if(!pieces.player1[a].side)
563 { 563 {
564 p1[a]->setX(pieces.player1[a].x); 564 p1[a]->setX(pieces.player1[a].x);
565 p1[a]->setY(pieces.player1[a].y); 565 p1[a]->setY(pieces.player1[a].y);
566 p1[a]->setZ(pieces.player1[a].z); 566 p1[a]->setZ(pieces.player1[a].z);
567 p1[a]->show(); 567 p1[a]->show();
568 p1_side[a]->hide(); 568 p1_side[a]->hide();
569 } 569 }
570 else 570 else
571 { 571 {
572 p1_side[a]->setX(pieces.player1[a].x); 572 p1_side[a]->setX(pieces.player1[a].x);
573 p1_side[a]->setY(pieces.player1[a].y); 573 p1_side[a]->setY(pieces.player1[a].y);
574 p1_side[a]->setZ(pieces.player1[a].z); 574 p1_side[a]->setZ(pieces.player1[a].z);
575 p1_side[a]->show(); 575 p1_side[a]->show();
576 p1[a]->hide(); 576 p1[a]->hide();
577 } 577 }
578 578
579 if(!pieces.player2[a].side) 579 if(!pieces.player2[a].side)
580 { 580 {
581 p2[a]->setX(pieces.player2[a].x); 581 p2[a]->setX(pieces.player2[a].x);
582 p2[a]->setY(pieces.player2[a].y); 582 p2[a]->setY(pieces.player2[a].y);
583 p2[a]->setZ(pieces.player2[a].z); 583 p2[a]->setZ(pieces.player2[a].z);
584 p2[a]->show(); 584 p2[a]->show();
585 p2_side[a]->hide(); 585 p2_side[a]->hide();
586 } 586 }
587 else 587 else
588 { 588 {
589 p2_side[a]->setX(pieces.player2[a].x); 589 p2_side[a]->setX(pieces.player2[a].x);
590 p2_side[a]->setY(pieces.player2[a].y); 590 p2_side[a]->setY(pieces.player2[a].y);
591 p2_side[a]->setZ(pieces.player2[a].z); 591 p2_side[a]->setZ(pieces.player2[a].z);
592 p2_side[a]->show(); 592 p2_side[a]->show();
593 p2[a]->hide(); 593 p2[a]->hide();
594 } 594 }
595 } 595 }
596} 596}
597 597
598void BackGammon::mouse(int x,int y) 598void BackGammon::mouse(int x,int y)
599{ 599{
600 if(gameFinished) 600 if(gameFinished)
601 { 601 {
602 newgame(); 602 newgame();
603 return; 603 return;
604 } 604 }
605 if(y<=200) //move pieces 605 if(y<=200) //move pieces
606 { 606 {
607 if((player==1 && player1_auto) || (player==2 && player2_auto)) 607 if((player==1 && player1_auto) || (player==2 && player2_auto))
608 return; 608 return;
609 609
610 Marker marker; 610 Marker marker;
611 611
612 move->boardpressed(x,y,marker); 612 move->boardpressed(x,y,marker);
613 if(marker.visible_current) 613 if(marker.visible_current)
614 { 614 {
615 marker_current->setX(marker.x_current); 615 marker_current->setX(marker.x_current);
616 marker_current->setY(marker.y_current); 616 marker_current->setY(marker.y_current);
617 marker_current->show(); 617 marker_current->show();
618 } 618 }
619 else 619 else
620 { 620 {
621 marker_current->hide(); 621 marker_current->hide();
622 } 622 }
623 623
624 for(int a=0;a<4;a++) 624 for(int a=0;a<4;a++)
625 { 625 {
626 if(marker.visible_next[a]) 626 if(marker.visible_next[a])
627 { 627 {
628 marker_next[a]->setX(marker.x_next[a]); 628 marker_next[a]->setX(marker.x_next[a]);
629 marker_next[a]->setY(marker.y_next[a]); 629 marker_next[a]->setY(marker.y_next[a]);
630 marker_next[a]->show(); 630 marker_next[a]->show();
631 } 631 }
632 else 632 else
633 { 633 {
634 marker_next[a]->hide(); 634 marker_next[a]->hide();
635 } 635 }
636 } 636 }
637 area->update(); 637 area->update();
638 } 638 }
639 else //roll dice 639 else //roll dice
640 { 640 {
641 if(x>=10 && x<=65 && player==1 && !dice_rolled) 641 if(x>=10 && x<=65 && player==1 && !dice_rolled)
642 { 642 {
643 dice1_played=false; 643 dice1_played=false;
644 dice2_played=false; 644 dice2_played=false;
645 dice3_played=false; 645 dice3_played=false;
646 dice4_played=false; 646 dice4_played=false;
647 dice_rolled=true; 647 dice_rolled=true;
648 srand(QTime::currentTime().msec()); 648 srand(QTime::currentTime().msec());
649 diceA1_value=1+(int) (6.0*rand()/(RAND_MAX+1.0)); 649 diceA1_value=1+(int) (6.0*rand()/(RAND_MAX+1.0));
650 diceA2_value=1+(int) (6.0*rand()/(RAND_MAX+1.0)); 650 diceA2_value=1+(int) (6.0*rand()/(RAND_MAX+1.0));
651 if(diceA1_value==diceA2_value) 651 if(diceA1_value==diceA2_value)
652 { 652 {
653 diceA3_value=diceA1_value; 653 diceA3_value=diceA1_value;
654 diceA4_value=diceA1_value; 654 diceA4_value=diceA1_value;
655 } 655 }
656 else 656 else
657 { 657 {
658 diceA3_value=7; 658 diceA3_value=7;
659 dice3_played=true; 659 dice3_played=true;
660 diceA4_value=7; 660 diceA4_value=7;
661 dice4_played=true; 661 dice4_played=true;
662 } 662 }
663 showdice(); 663 showdice();
664 area->update(); 664 area->update();
665 move->diceroll(1,diceA1_value,diceA2_value,diceA3_value,diceA4_value,player1_auto); 665 move->diceroll(1,diceA1_value,diceA2_value,diceA3_value,diceA4_value,player1_auto);
666 666
667 } 667 }
668 else if(x>=160 && x<=225 && player==2 && !dice_rolled) 668 else if(x>=160 && x<=225 && player==2 && !dice_rolled)
669 { 669 {
670 dice1_played=false; 670 dice1_played=false;
671 dice2_played=false; 671 dice2_played=false;
672 dice3_played=false; 672 dice3_played=false;
673 dice4_played=false; 673 dice4_played=false;
674 dice_rolled=true; 674 dice_rolled=true;
675 srand(QTime::currentTime().msec()); 675 srand(QTime::currentTime().msec());
676 diceB1_value=1+(int) (6.0*rand()/(RAND_MAX+1.0)); 676 diceB1_value=1+(int) (6.0*rand()/(RAND_MAX+1.0));
677 diceB2_value=1+(int) (6.0*rand()/(RAND_MAX+1.0)); 677 diceB2_value=1+(int) (6.0*rand()/(RAND_MAX+1.0));
678 if(diceB1_value==diceB2_value) 678 if(diceB1_value==diceB2_value)
679 { 679 {
680 diceB3_value=diceB1_value; 680 diceB3_value=diceB1_value;
681 diceB4_value=diceB1_value; 681 diceB4_value=diceB1_value;
682 } 682 }
683 else 683 else
684 { 684 {
685 diceB3_value=7; 685 diceB3_value=7;
686 dice3_played=true; 686 dice3_played=true;
687 diceB4_value=7; 687 diceB4_value=7;
688 dice4_played=true; 688 dice4_played=true;
689 } 689 }
690 showdice(); 690 showdice();
691 area->update(); 691 area->update();
692 move->diceroll(2,diceB1_value,diceB2_value,diceB3_value,diceB4_value,player2_auto); 692 move->diceroll(2,diceB1_value,diceB2_value,diceB3_value,diceB4_value,player2_auto);
693 } 693 }
694 } 694 }
695} 695}
696 696
697void BackGammon::done_dice1() 697void BackGammon::done_dice1()
698{ 698{
699 dice1_played=true; 699 dice1_played=true;
700 if(player==1) 700 if(player==1)
701 diceA1_value=7; 701 diceA1_value=7;
702 else 702 else
703 diceB1_value=7; 703 diceB1_value=7;
704 setplayer(); 704 setplayer();