summaryrefslogtreecommitdiff
path: root/noncore/games
Unidiff
Diffstat (limited to 'noncore/games') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/backgammon/moveengine.cpp6
-rw-r--r--noncore/games/kbill/UI.cpp31
-rw-r--r--noncore/games/kcheckers/echeckers.cpp12
-rw-r--r--noncore/games/kcheckers/rcheckers.cpp36
4 files changed, 49 insertions, 36 deletions
diff --git a/noncore/games/backgammon/moveengine.cpp b/noncore/games/backgammon/moveengine.cpp
index a4145cc..b102258 100644
--- a/noncore/games/backgammon/moveengine.cpp
+++ b/noncore/games/backgammon/moveengine.cpp
@@ -44,25 +44,26 @@ void MoveEngine::position(Pieces& pieces,bool non_qte)
44 int player1_counter=0; 44 int player1_counter=0;
45 int player2_counter=0; 45 int player2_counter=0;
46 46
47 //non qte styles are smaller !! 47 //non qte styles are smaller !!
48 int offset=(non_qte) ? 5 : 0; 48 int offset=(non_qte) ? 5 : 0;
49 49
50 for(int a=0;a<28;a++) 50 for(int a=0;a<28;a++)
51 { 51 {
52 for(int b=0;b<abs(population[a].total);b++) 52 for(int b=0;b<abs(population[a].total);b++)
53 { 53 {
54 if(population[a].total>0) //player 1 pieces 54 if(population[a].total>0) //player 1 pieces
55 { 55 {
56 pieces.player1[player1_counter].x=x_coord[a]-offset; 56 if (a < 26)
57 pieces.player1[player1_counter].x=x_coord[a]-offset;
57 if(a>=0 && a<13) 58 if(a>=0 && a<13)
58 { 59 {
59 pieces.player1[player1_counter].y=yup_coord[b]-offset; 60 pieces.player1[player1_counter].y=yup_coord[b]-offset;
60 pieces.player1[player1_counter].z=z_coord[b]; 61 pieces.player1[player1_counter].z=z_coord[b];
61 pieces.player1[player1_counter].side=false; 62 pieces.player1[player1_counter].side=false;
62 player1_counter++; 63 player1_counter++;
63 } 64 }
64 else if(a>12 && a<26) 65 else if(a>12 && a<26)
65 { 66 {
66 pieces.player1[player1_counter].y=ylow_coord[b]-offset; 67 pieces.player1[player1_counter].y=ylow_coord[b]-offset;
67 pieces.player1[player1_counter].z=z_coord[b]; 68 pieces.player1[player1_counter].z=z_coord[b];
68 pieces.player1[player1_counter].side=false; 69 pieces.player1[player1_counter].side=false;
@@ -87,25 +88,26 @@ void MoveEngine::position(Pieces& pieces,bool non_qte)
87 pieces.player1[player1_counter].x=x_fin1[2]-offset; 88 pieces.player1[player1_counter].x=x_fin1[2]-offset;
88 pieces.player1[player1_counter].y=y_fin[b-10]-offset; 89 pieces.player1[player1_counter].y=y_fin[b-10]-offset;
89 pieces.player1[player1_counter].z=z_fin; 90 pieces.player1[player1_counter].z=z_fin;
90 } 91 }
91 pieces.player1[player1_counter].side=true; 92 pieces.player1[player1_counter].side=true;
92 player1_counter++; 93 player1_counter++;
93 94
94 } 95 }
95 } 96 }
96 97
97 else if(population[a].total<0) //player 2 pieces 98 else if(population[a].total<0) //player 2 pieces
98 { 99 {
99 pieces.player2[player2_counter].x=x_coord[a]-offset; 100 if (a < 26)
101 pieces.player2[player2_counter].x=x_coord[a]-offset;
100 if(a>=0 && a<13) 102 if(a>=0 && a<13)
101 { 103 {
102 pieces.player2[player2_counter].y=yup_coord[b]-offset; 104 pieces.player2[player2_counter].y=yup_coord[b]-offset;
103 pieces.player2[player2_counter].z=z_coord[b]; 105 pieces.player2[player2_counter].z=z_coord[b];
104 pieces.player2[player2_counter].side=false; 106 pieces.player2[player2_counter].side=false;
105 player2_counter++; 107 player2_counter++;
106 } 108 }
107 else if(a>12 && a<26) 109 else if(a>12 && a<26)
108 { 110 {
109 pieces.player2[player2_counter].y=ylow_coord[b]-offset; 111 pieces.player2[player2_counter].y=ylow_coord[b]-offset;
110 pieces.player2[player2_counter].z=z_coord[b]; 112 pieces.player2[player2_counter].z=z_coord[b];
111 pieces.player2[player2_counter].side=false; 113 pieces.player2[player2_counter].side=false;
diff --git a/noncore/games/kbill/UI.cpp b/noncore/games/kbill/UI.cpp
index 611cebf..a49c3c1 100644
--- a/noncore/games/kbill/UI.cpp
+++ b/noncore/games/kbill/UI.cpp
@@ -59,46 +59,45 @@ void UI::graph_init() {
59 59
60void UI::make_mainwin() { 60void UI::make_mainwin() {
61 main = new KBill(); 61 main = new KBill();
62 app->showMainWidget(main,true); 62 app->showMainWidget(main,true);
63 main->showMaximized(); 63 main->showMaximized();
64 field = main->getField(); 64 field = main->getField();
65} 65}
66 66
67void UI::popup_dialog (int dialog) { 67void UI::popup_dialog (int dialog) {
68 kill_timer(); 68 kill_timer();
69 switch (dialog) { 69 switch (dialog) {
70 case Game::ENDGAME: 70 case Game::ENDGAME:
71 QMessageBox::message(("Endgame"), QT_TR_NOOP(endgamestr)); 71 QMessageBox::message(("Endgame"), QT_TR_NOOP(endgamestr));
72 break; 72 break;
73 case Game::HIGHSCORE: 73 case Game::HIGHSCORE:
74 //QMessageBox::message(("HighScore"), highscorestr); 74 break;
75 break; 75 case Game::ENTERNAME:
76 case Game::ENTERNAME: { 76 {
77 InputBox b(main, 0, ("Enter Name"), QT_TR_NOOP(enternamestr)); 77 InputBox b(main, 0, ("Enter Name"), QT_TR_NOOP(enternamestr));
78 bool state = b.exec() == 2; 78 bool state = b.exec() == 2;
79 char str[20], *nl; 79 char str[20], *nl;
80 strcpy(str, b.getText()); 80 strncpy(str, b.getText(), 19);
81 if (!str[0] || state) 81 if (!str[0] || state)
82 strcpy(str, "Anonymous"); 82 strcpy(str, "Anonymous");
83 else if ((nl = strchr(str, '\n'))) 83 else if ((nl = strchr(str, '\n')))
84 *nl = '\0'; 84 *nl = '\0';
85 if (strlen(str) > 20) 85 if (strlen(str) > 19)
86 str[20] = 0; /* truncate string if too long */ 86 str[19] = '\0'; /* truncate/terminate the string if it is too long */
87 // scores.recalc(str); 87 }
88 } 88 break;
89 break;
90 case Game::SCORE: 89 case Game::SCORE:
91 QMessageBox::message(("Score"), scorestr); 90 QMessageBox::message(("Score"), scorestr);
92 break; 91 break;
93 } 92 }
94 restart_timer(); 93 restart_timer();
95} 94}
96 95
97/*********************/ 96/*********************/
98/* Graphics routines */ 97/* Graphics routines */
99/*********************/ 98/*********************/
100 99
101void UI::set_cursor(int cursor) { 100void UI::set_cursor(int cursor) {
102 QCursor *cur; 101 QCursor *cur;
103 switch (cursor) { 102 switch (cursor) {
104 case Game::BUCKETC: 103 case Game::BUCKETC:
diff --git a/noncore/games/kcheckers/echeckers.cpp b/noncore/games/kcheckers/echeckers.cpp
index 1146059..afe62eb 100644
--- a/noncore/games/kcheckers/echeckers.cpp
+++ b/noncore/games/kcheckers/echeckers.cpp
@@ -70,27 +70,27 @@ bool ECheckers::checkCapture1()
70 case MAN1: 70 case MAN1:
71 if(board[i-6]==MAN2 || board[i-6]==KING2) 71 if(board[i-6]==MAN2 || board[i-6]==KING2)
72 if(board[i-12]==FREE) return true; 72 if(board[i-12]==FREE) return true;
73 if(board[i-5]==MAN2 || board[i-5]==KING2) 73 if(board[i-5]==MAN2 || board[i-5]==KING2)
74 if(board[i-10]==FREE) return true; 74 if(board[i-10]==FREE) return true;
75 break; 75 break;
76 case KING1: 76 case KING1:
77 if(board[i-6]==MAN2 || board[i-6]==KING2) 77 if(board[i-6]==MAN2 || board[i-6]==KING2)
78 if(board[i-12]==FREE) return true; 78 if(board[i-12]==FREE) return true;
79 if(board[i-5]==MAN2 || board[i-5]==KING2) 79 if(board[i-5]==MAN2 || board[i-5]==KING2)
80 if(board[i-10]==FREE) return true; 80 if(board[i-10]==FREE) return true;
81 if(board[i+5]==MAN2 || board[i+5]==KING2) 81 if(board[i+5]==MAN2 || board[i+5]==KING2)
82 if(board[i+10]==FREE) return true; 82 if(board[((i+10) < 54) ? i+10 : 53]==FREE) return true;
83 if(board[i+6]==MAN2 || board[i+6]==KING2) 83 if(board[i+6]==MAN2 || board[i+6]==KING2)
84 if(board[i+12]==FREE) return true; 84 if(board[((i+12) < 54) ? i+12 : 53]==FREE) return true;
85 } 85 }
86 } 86 }
87 return false; 87 return false;
88} 88}
89 89
90 90
91// Return TRUE if a course of the user true 91// Return TRUE if a course of the user true
92// Return FALSE if a course of the user incorrect 92// Return FALSE if a course of the user incorrect
93 93
94bool ECheckers::manCapture1(int from,int direction,bool &capture) 94bool ECheckers::manCapture1(int from,int direction,bool &capture)
95{ 95{
96 int i=from+direction; 96 int i=from+direction;
@@ -212,37 +212,37 @@ void ECheckers::kingMove2(int from,int &resMax)
212 board[from]=KING2; 212 board[from]=KING2;
213} 213}
214 214
215 215
216bool ECheckers::checkCapture2() 216bool ECheckers::checkCapture2()
217{ 217{
218 for(int i=6;i<48;i++) 218 for(int i=6;i<48;i++)
219 { 219 {
220 switch(board[i]) 220 switch(board[i])
221 { 221 {
222 case MAN2: 222 case MAN2:
223 if(board[i+5]==MAN1 || board[i+5]==KING1) 223 if(board[i+5]==MAN1 || board[i+5]==KING1)
224 if(board[i+10]==FREE) return true; 224 if(board[((i+10) < 54) ? i+10 : 53]==FREE) return true;
225 if(board[i+6]==MAN1 || board[i+6]==KING1) 225 if(board[i+6]==MAN1 || board[i+6]==KING1)
226 if(board[i+12]==FREE) return true; 226 if(board[((i+12) < 54) ? i+12 : 53]==FREE) return true;
227 break; 227 break;
228 case KING2: 228 case KING2:
229 if(board[i-6]==MAN1 || board[i-6]==KING1) 229 if(board[i-6]==MAN1 || board[i-6]==KING1)
230 if(board[i-12]==FREE) return true; 230 if(board[i-12]==FREE) return true;
231 if(board[i-5]==MAN1 || board[i-5]==KING1) 231 if(board[i-5]==MAN1 || board[i-5]==KING1)
232 if(board[i-10]==FREE) return true; 232 if(board[i-10]==FREE) return true;
233 if(board[i+5]==MAN1 || board[i+5]==KING1) 233 if(board[i+5]==MAN1 || board[i+5]==KING1)
234 if(board[i+10]==FREE) return true; 234 if(board[((i+10) < 54) ? i+10 : 53]==FREE) return true;
235 if(board[i+6]==MAN1 || board[i+6]==KING1) 235 if(board[i+6]==MAN1 || board[i+6]==KING1)
236 if(board[i+12]==FREE) return true; 236 if(board[((i+12) < 54) ? i+12 : 53]==FREE) return true;
237 } 237 }
238 } 238 }
239 return false; 239 return false;
240} 240}
241 241
242 242
243// Return TRUE if it is possible to capture 243// Return TRUE if it is possible to capture
244// Return FALSE if it is impossible to capture 244// Return FALSE if it is impossible to capture
245 245
246bool ECheckers::manCapture2(int from,int &resMax) 246bool ECheckers::manCapture2(int from,int &resMax)
247{ 247{
248 bool capture=false; 248 bool capture=false;
diff --git a/noncore/games/kcheckers/rcheckers.cpp b/noncore/games/kcheckers/rcheckers.cpp
index a1c7afa..d808780 100644
--- a/noncore/games/kcheckers/rcheckers.cpp
+++ b/noncore/games/kcheckers/rcheckers.cpp
@@ -103,45 +103,51 @@ bool RCheckers::go1(int from,int field)
103bool RCheckers::checkCapture1() 103bool RCheckers::checkCapture1()
104{ 104{
105 for(int i=6;i<48;i++) 105 for(int i=6;i<48;i++)
106 { 106 {
107 switch(board[i]) 107 switch(board[i])
108 { 108 {
109 case MAN1: 109 case MAN1:
110 if(board[i-6]==MAN2 || board[i-6]==KING2) 110 if(board[i-6]==MAN2 || board[i-6]==KING2)
111 if(board[i-12]==FREE) return true; 111 if(board[i-12]==FREE) return true;
112 if(board[i-5]==MAN2 || board[i-5]==KING2) 112 if(board[i-5]==MAN2 || board[i-5]==KING2)
113 if(board[i-10]==FREE) return true; 113 if(board[i-10]==FREE) return true;
114 if(board[i+5]==MAN2 || board[i+5]==KING2) 114 if(board[i+5]==MAN2 || board[i+5]==KING2)
115 if(board[i+10]==FREE) return true; 115 if(board[((i+10) < 54) ? i+10 : 53]==FREE) return true;
116 if(board[i+6]==MAN2 || board[i+6]==KING2) 116 if(board[i+6]==MAN2 || board[i+6]==KING2)
117 if(board[i+12]==FREE) return true; 117 if(board[((i+12) < 54) ? i+12 : 53]==FREE) return true;
118 break; 118 break;
119 case KING1: 119 case KING1:
120 int k; 120 int k;
121 for(k=i-6;board[k]==FREE;k-=6); 121 for(k=i-6;board[k]==FREE;k-=6);
122 if(board[k]==MAN2 || board[k]==KING2) 122 if(board[k]==MAN2 || board[k]==KING2)
123 if(board[k-6]==FREE) return true; 123 if(board[k-6]==FREE) return true;
124 124
125 for(k=i-5;board[k]==FREE;k-=5); 125 for(k=i-5;board[k]==FREE;k-=5);
126 if(board[k]==MAN2 || board[k]==KING2) 126 if(board[k]==MAN2 || board[k]==KING2)
127 if(board[k-5]==FREE) return true; 127 if(board[k-5]==FREE) return true;
128 128
129 for(k=i+5;board[k]==FREE;k+=5); 129 for(k=i+5;board[k]==FREE;k+=5) {
130 if (k >= 49)
131 break;
132 }
130 if(board[k]==MAN2 || board[k]==KING2) 133 if(board[k]==MAN2 || board[k]==KING2)
131 if(board[k+5]==FREE) return true; 134 if(board[((k+5) < 54) ? k+5 : 53]==FREE) return true;
132 135
133 for(k=i+6;board[k]==FREE;k+=6); 136 for(k=i+6;board[k]==FREE;k+=6) {
137 if (k >=48)
138 break;
139 }
134 if(board[k]==MAN2 || board[k]==KING2) 140 if(board[k]==MAN2 || board[k]==KING2)
135 if(board[k+6]==FREE) return true; 141 if(board[((k+6) < 54) ? k+6 : 53]==FREE) return true;
136 } 142 }
137 } 143 }
138 return false; 144 return false;
139} 145}
140 146
141 147
142// Return TRUE if a course of the user true 148// Return TRUE if a course of the user true
143// Return FALSE if a course of the user incorrect 149// Return FALSE if a course of the user incorrect
144 150
145bool RCheckers::manCapture1(int from,int direction,bool &capture) 151bool RCheckers::manCapture1(int from,int direction,bool &capture)
146{ 152{
147 int i=from+direction; 153 int i=from+direction;
@@ -277,45 +283,51 @@ void RCheckers::kingMove2(int from,int &resMax)
277bool RCheckers::checkCapture2() 283bool RCheckers::checkCapture2()
278{ 284{
279 for(int i=6;i<48;i++) 285 for(int i=6;i<48;i++)
280 { 286 {
281 switch(board[i]) 287 switch(board[i])
282 { 288 {
283 case MAN2: 289 case MAN2:
284 if(board[i-6]==MAN1 || board[i-6]==KING1) 290 if(board[i-6]==MAN1 || board[i-6]==KING1)
285 if(board[i-12]==FREE) return true; 291 if(board[i-12]==FREE) return true;
286 if(board[i-5]==MAN1 || board[i-5]==KING1) 292 if(board[i-5]==MAN1 || board[i-5]==KING1)
287 if(board[i-10]==FREE) return true; 293 if(board[i-10]==FREE) return true;
288 if(board[i+5]==MAN1 || board[i+5]==KING1) 294 if(board[i+5]==MAN1 || board[i+5]==KING1)
289 if(board[i+10]==FREE) return true; 295 if(board[((i+10) < 54) ? i+10 : 53]==FREE) return true;
290 if(board[i+6]==MAN1 || board[i+6]==KING1) 296 if(board[i+6]==MAN1 || board[i+6]==KING1)
291 if(board[i+12]==FREE) return true; 297 if(board[((i+12) < 54) ? i+12 : 53]==FREE) return true;
292 break; 298 break;
293 case KING2: 299 case KING2:
294 int k; 300 int k;
295 for(k=i-6;board[k]==FREE;k-=6); 301 for(k=i-6;board[k]==FREE;k-=6);
296 if(board[k]==MAN1 || board[k]==KING1) 302 if(board[k]==MAN1 || board[k]==KING1)
297 if(board[k-6]==FREE) return true; 303 if(board[k-6]==FREE) return true;
298 304
299 for(k=i-5;board[k]==FREE;k-=5); 305 for(k=i-5;board[k]==FREE;k-=5);
300 if(board[k]==MAN1 || board[k]==KING1) 306 if(board[k]==MAN1 || board[k]==KING1)
301 if(board[k-5]==FREE) return true; 307 if(board[k-5]==FREE) return true;
302 308
303 for(k=i+5;board[k]==FREE;k+=5); 309 for(k=i+5;board[k]==FREE;k+=5) {
310 if (k>=49)
311 break;
312 }
304 if(board[k]==MAN1 || board[k]==KING1) 313 if(board[k]==MAN1 || board[k]==KING1)
305 if(board[k+5]==FREE) return true; 314 if(board[((k+5) < 54) ? k+5 : 53]==FREE) return true;
306 315
307 for(k=i+6;board[k]==FREE;k+=6); 316 for(k=i+6;board[k]==FREE;k+=6) {
317 if (k>=48)
318 break;
319 }
308 if(board[k]==MAN1 || board[k]==KING1) 320 if(board[k]==MAN1 || board[k]==KING1)
309 if(board[k+6]==FREE) return true; 321 if(board[((k+6) < 54) ? k+6 : 53]==FREE) return true;
310 } 322 }
311 } 323 }
312 return false; 324 return false;
313} 325}
314 326
315 327
316// Return TRUE if it is possible to capture 328// Return TRUE if it is possible to capture
317// Return FALSE if it is impossible to capture 329// Return FALSE if it is impossible to capture
318 330
319bool RCheckers::manCapture2(int from,int &resMax) 331bool RCheckers::manCapture2(int from,int &resMax)
320{ 332{
321 bool capture=false; 333 bool capture=false;