-rw-r--r-- | noncore/games/backgammon/backgammon.cpp | 16 | ||||
-rw-r--r-- | noncore/games/backgammon/moveengine.cpp | 2 |
2 files changed, 11 insertions, 7 deletions
diff --git a/noncore/games/backgammon/backgammon.cpp b/noncore/games/backgammon/backgammon.cpp index 51020a0..bdb1c78 100644 --- a/noncore/games/backgammon/backgammon.cpp +++ b/noncore/games/backgammon/backgammon.cpp | |||
@@ -1,48 +1,52 @@ | |||
1 | #include "backgammon.h" | 1 | #include "backgammon.h" |
2 | |||
3 | #include "aidialog.h" | 2 | #include "aidialog.h" |
4 | #include "filedialog.h" | 3 | #include "filedialog.h" |
5 | #include "playerdialog.h" | 4 | #include "playerdialog.h" |
6 | #include "rulesdialog.h" | 5 | #include "rulesdialog.h" |
7 | #include "themedialog.h" | 6 | #include "themedialog.h" |
8 | 7 | ||
8 | /* OPIE */ | ||
9 | #include <opie2/odebug.h> | ||
10 | #include <qpe/qpeapplication.h> | ||
11 | #include <qpe/config.h> | ||
12 | #include <qpe/resource.h> | ||
13 | using namespace Opie::Core; | ||
14 | |||
15 | /* QT */ | ||
9 | #include <qfile.h> | 16 | #include <qfile.h> |
10 | #include <qlayout.h> | 17 | #include <qlayout.h> |
11 | #include <qmessagebox.h> | 18 | #include <qmessagebox.h> |
12 | #include <qtimer.h> | 19 | #include <qtimer.h> |
13 | #include <qpe/qpeapplication.h> | ||
14 | #include <qpe/config.h> | ||
15 | #include <qmenubar.h> | 20 | #include <qmenubar.h> |
16 | #include <qpe/resource.h> | ||
17 | 21 | ||
18 | #include <stdlib.h> | 22 | #include <stdlib.h> |
19 | 23 | ||
20 | 24 | ||
21 | BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) | 25 | BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) |
22 | : QMainWindow(parent, name, fl) | 26 | : QMainWindow(parent, name, fl) |
23 | { | 27 | { |
24 | if (!name) setName("BackGammon"); | 28 | if (!name) setName("BackGammon"); |
25 | setCaption(tr( "Backgammon") ); | 29 | setCaption(tr( "Backgammon") ); |
26 | setIcon( Resource::loadPixmap( "backgammon" ) ); | 30 | setIcon( Resource::loadPixmap( "backgammon" ) ); |
27 | //general counter varaible | 31 | //general counter varaible |
28 | int a=0; | 32 | int a=0; |
29 | //the game engine | 33 | //the game engine |
30 | move=new MoveEngine(); | 34 | move=new MoveEngine(); |
31 | 35 | ||
32 | //load the default theme | 36 | //load the default theme |
33 | Config conf("backgammon"); | 37 | Config conf("backgammon"); |
34 | if(!conf.isValid()) | 38 | if(!conf.isValid()) |
35 | { | 39 | { |
36 | qDebug("config file does not exist"); | 40 | odebug << "config file does not exist" << oendl; |
37 | conf.setGroup("general"); | 41 | conf.setGroup("general"); |
38 | conf.writeEntry("theme","default"); | 42 | conf.writeEntry("theme","default"); |
39 | conf.setGroup("rules"); | 43 | conf.setGroup("rules"); |
40 | conf.writeEntry("move_with_pieces_out",false); | 44 | conf.writeEntry("move_with_pieces_out",false); |
41 | conf.writeEntry("nice_dice",false); | 45 | conf.writeEntry("nice_dice",false); |
42 | conf.setGroup("display"); | 46 | conf.setGroup("display"); |
43 | conf.writeEntry("small",false); | 47 | conf.writeEntry("small",false); |
44 | conf.writeEntry("warning",true); | 48 | conf.writeEntry("warning",true); |
45 | conf.setGroup("ai"); | 49 | conf.setGroup("ai"); |
46 | conf.writeEntry("rescue",6); | 50 | conf.writeEntry("rescue",6); |
47 | conf.writeEntry("eliminate",4); | 51 | conf.writeEntry("eliminate",4); |
48 | conf.writeEntry("expose",1); | 52 | conf.writeEntry("expose",1); |
@@ -69,25 +73,25 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) | |||
69 | ai.eliminate=conf.readNumEntry("eliminate",4); | 73 | ai.eliminate=conf.readNumEntry("eliminate",4); |
70 | ai.expose=conf.readNumEntry("expose",1); | 74 | ai.expose=conf.readNumEntry("expose",1); |
71 | ai.protect=conf.readNumEntry("protect",5); | 75 | ai.protect=conf.readNumEntry("protect",5); |
72 | ai.safe=conf.readNumEntry("safe",3); | 76 | ai.safe=conf.readNumEntry("safe",3); |
73 | ai.empty=conf.readNumEntry("empty",2); | 77 | ai.empty=conf.readNumEntry("empty",2); |
74 | move->setAISettings(ai); | 78 | move->setAISettings(ai); |
75 | 79 | ||
76 | 80 | ||
77 | //get the theme component names | 81 | //get the theme component names |
78 | Config theme(theme_file,Config::File); | 82 | Config theme(theme_file,Config::File); |
79 | if(!theme.isValid()) | 83 | if(!theme.isValid()) |
80 | { | 84 | { |
81 | qDebug("theme file does not exist"); | 85 | odebug << "theme file does not exist" << oendl; |
82 | theme.setGroup("theme"); | 86 | theme.setGroup("theme"); |
83 | theme.writeEntry("board","casino_board_1"); | 87 | theme.writeEntry("board","casino_board_1"); |
84 | theme.writeEntry("pieces1","casino_pieces_blue"); | 88 | theme.writeEntry("pieces1","casino_pieces_blue"); |
85 | theme.writeEntry("pieces2","casino_pieces_white"); | 89 | theme.writeEntry("pieces2","casino_pieces_white"); |
86 | theme.writeEntry("dice1","casino_dice"); | 90 | theme.writeEntry("dice1","casino_dice"); |
87 | theme.writeEntry("dice2","casino_dice"); | 91 | theme.writeEntry("dice2","casino_dice"); |
88 | theme.writeEntry("table","casino_table_green"); | 92 | theme.writeEntry("table","casino_table_green"); |
89 | theme.writeEntry("odds","casino_odds"); | 93 | theme.writeEntry("odds","casino_odds"); |
90 | } | 94 | } |
91 | theme.setGroup("theme"); | 95 | theme.setGroup("theme"); |
92 | board_name=theme.readEntry("board","casino_board_1"); | 96 | board_name=theme.readEntry("board","casino_board_1"); |
93 | piecesA_name=theme.readEntry("pieces1","casino_pieces_blue"); | 97 | piecesA_name=theme.readEntry("pieces1","casino_pieces_blue"); |
diff --git a/noncore/games/backgammon/moveengine.cpp b/noncore/games/backgammon/moveengine.cpp index 7de7147..a4145cc 100644 --- a/noncore/games/backgammon/moveengine.cpp +++ b/noncore/games/backgammon/moveengine.cpp | |||
@@ -448,25 +448,25 @@ int MoveEngine::getPossibleMoves() | |||
448 | } | 448 | } |
449 | 449 | ||
450 | int total=0; | 450 | int total=0; |
451 | for(int field=0;field<26;field++) | 451 | for(int field=0;field<26;field++) |
452 | { | 452 | { |
453 | total+=moves[field].weight[0]+moves[field].weight[1]+moves[field].weight[2]+moves[field].weight[3]; | 453 | total+=moves[field].weight[0]+moves[field].weight[1]+moves[field].weight[2]+moves[field].weight[3]; |
454 | } | 454 | } |
455 | return total; | 455 | return total; |
456 | } | 456 | } |
457 | 457 | ||
458 | void MoveEngine::move(const int& from, int to, const int& dice) | 458 | void MoveEngine::move(const int& from, int to, const int& dice) |
459 | { | 459 | { |
460 | //qDebug("%d moves from %d to %d (%d) with dice %d",player,from,to,to-from,dice); | 460 | //odebug << "" << player << " moves from " << from << " to " << to << " (" << to-from << ") with dice " << dice << "" << oendl; |
461 | 461 | ||
462 | if(player==1 && to==25) | 462 | if(player==1 && to==25) |
463 | to=26; | 463 | to=26; |
464 | if(player==2 && to==0) | 464 | if(player==2 && to==0) |
465 | to=27; | 465 | to=27; |
466 | 466 | ||
467 | //if space is occupied by enemy move pieces to startzone | 467 | //if space is occupied by enemy move pieces to startzone |
468 | if(fieldColor(to)==otherplayer) | 468 | if(fieldColor(to)==otherplayer) |
469 | { | 469 | { |
470 | population[to].total=0; | 470 | population[to].total=0; |
471 | if(otherplayer==1) | 471 | if(otherplayer==1) |
472 | population[0].total++; | 472 | population[0].total++; |