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
@@ -12,97 +12,97 @@
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);
@@ -283,278 +283,278 @@ BackGammon::~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++)