/
Play.cpp
700 lines (652 loc) · 21.2 KB
/
Play.cpp
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
//play.cpp
#include "StdAfx.h"
#include "play.h"
#include "Checkers.h"
//--------------------------------------------------------------------------
//
// This file contains the implementation of the class CPlay
//
//--------------------------------------------------------------------------
// Programmer : Sergey Borovik
// Email : sbsergey@hotmail.com
// Date : 27/04/04
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
// Constructor
//--------------------------------------------------------------------------
CPlay::CPlay(void):m_Turn(BLUE)
{
}
//--------------------------------------------------------------------------
// Destructor
//--------------------------------------------------------------------------
CPlay::~CPlay(void)
{
}
//Acsess methods
int CPlay::GetTurn()
{ return m_Turn; }
int CPlay::IsChecker(int x,int y)
{ return (m_Board[y+WALL_SIZE][x+WALL_SIZE]); }
void CPlay::GetNumCheckers(int &red, int &blue)
{
red = numRedCheckers;
blue = numBlueCheckers;
}
//Modify methods
void CPlay::SetTurn(int _turn)
{ m_Turn = _turn; }
void CPlay::SetActiveChecker(int x, int y)
{
m_Active.x = x;
m_Active.y = y;
}
void CPlay::ChangeTurn()
{ m_Turn = -m_Turn; }
void CPlay::IncCheckersNum()
{
if(m_Turn == BLUE)
numRedCheckers++;
else numBlueCheckers++;
}
//Other methods
bool CPlay::IsGameOver()
{
return ((numRedCheckers == MAX_CHECKERS) ||
(numBlueCheckers == MAX_CHECKERS) );
}
//--------------------------------------------------------------------------
// Start
// -----
// General : Initializes all the class members
// (including setting checkers)
// Parameters : None
// Return Value : None
//--------------------------------------------------------------------------
void CPlay::Start()
{
int i,j;
int redCount,blueCount;
for (redCount = 0, blueCount = 0,i = 0; i<GAMEBOARD_SIZE; i++)
for (j = 0; j<GAMEBOARD_SIZE; j++)
{
if(i>=GAMEBOARD_SIZE-WALL_SIZE || j>=GAMEBOARD_SIZE-WALL_SIZE ||
i < WALL_SIZE || j < WALL_SIZE)
m_Board[i][j] = WALL;
else if(i<3+WALL_SIZE)
{
if((i+j)%2)
{
pRedCheckers[redCount].x = j;
pRedCheckers[redCount++].y = i;
}
m_Board[i][j] = ((i+j)%2);
}
else if(i>BOARD_SIZE-2)
{
if((i+j)%2)
{
pBlueCheckers[blueCount].x = j;
pBlueCheckers[blueCount++].y = i;
}
m_Board[i][j] = -1*(i+j)%2;
}
else
m_Board[i][j] = 0;
}
ClearPossibleMoves();
m_Active.x = NONE;
m_Active.y = NONE;
m_MustJump = 0;
numBlueCheckers = 0;
numRedCheckers = 0;
}
//--------------------------------------------------------------------------
// ClearPossibleMoves
// ------------------
// General : Clears the moves array
// Parameters : None
// Return Value : None
//--------------------------------------------------------------------------
inline void CPlay::ClearPossibleMoves()
{
for (int i = 0; i<MAX_MOVES; i++)
{
m_Moves[i].x = NONE;
m_Moves[i].y = NONE;
}
}
//--------------------------------------------------------------------------
// DrawCheckers
// ------------
// General : Draws checkers on the screen
// Parameters : opp1 - HDC (device context)
// Return Value : None
//--------------------------------------------------------------------------
void CPlay::DrawCheckers(HDC& hdc)
{
CHECKERS brushFlag = REDCHECKER;
//creating brushes for coloring
HBRUSH red,blue;
red = CreateSolidBrush(RGB(200,30,30));
blue = CreateSolidBrush(RGB(80,80,250));
SelectObject(hdc,red);
//scanning the matrix
for(int i = WALL_SIZE - 1; i<BOARD_SIZE+WALL_SIZE; i++)
for (int j = WALL_SIZE - 1; j<BOARD_SIZE+WALL_SIZE; j++)
if(m_Board[i][j]!= EMPTY)
{
if(m_Board[i][j] == BLUECHECKER || m_Board[i][j] == BLUEKING)
{
if(brushFlag == REDCHECKER)
{
//pick blue color
brushFlag = BLUECHECKER;
SelectObject(hdc,blue);
}
}
else
if(brushFlag == BLUECHECKER)
{
//pick red color
brushFlag = REDCHECKER;
SelectObject(hdc,red);
}
//draw checker
Ellipse(hdc,(j-WALL_SIZE)*SQUARE_SIZE,(i-WALL_SIZE)*SQUARE_SIZE,
SQUARE_SIZE+(j-WALL_SIZE)*SQUARE_SIZE,SQUARE_SIZE+
(i-WALL_SIZE)*SQUARE_SIZE);
//draw smaller ellipse in middle if king
if(m_Board[i][j]%2 == 0)
Ellipse(hdc,(j-WALL_SIZE)*SQUARE_SIZE+10,(i-WALL_SIZE)*SQUARE_SIZE+10,
30+(j-WALL_SIZE)*SQUARE_SIZE,30+(i-WALL_SIZE)*SQUARE_SIZE);
}
DeleteObject(red);
DeleteObject(blue);
}
//--------------------------------------------------------------------------
// DrawActiveChecker
// -----------------
// General : Draws currently active checker
// Parameters : opp1 - HDC (device context)
// Return Value : None
//--------------------------------------------------------------------------
void CPlay::DrawActiveChecker(HDC &hdc)
{
//brushes
HBRUSH red,blue;
red = CreateSolidBrush(RGB(200,130,130));
blue = CreateSolidBrush(RGB(180,180,250));
//choose brush
if((m_Board[m_Active.y][m_Active.x] - m_Board[m_Active.y][m_Active.x]/2) == RED)
SelectObject(hdc,red);
else SelectObject(hdc,blue);
//draw the checker
Ellipse(hdc,(m_Active.x - WALL_SIZE)*SQUARE_SIZE,
(m_Active.y - WALL_SIZE)*SQUARE_SIZE,
(m_Active.x - WALL_SIZE)*SQUARE_SIZE + SQUARE_SIZE,
(m_Active.y - WALL_SIZE)*SQUARE_SIZE + SQUARE_SIZE);
DeleteObject(red);
DeleteObject(blue);
}
//--------------------------------------------------------------------------
// DrawActiveChecker
// -----------------
// General : Draws possible moves for currently
// active checker
// Parameters : opp1 - HDC (device context)
// Return Value : None
//--------------------------------------------------------------------------
void CPlay::DrawPossibleMoves(HDC &hdc)
{
//brush
HBRUSH white;
white = CreateSolidBrush(RGB(220,220,220));
SelectObject(hdc,white);
//draw possible moves
for (int i = 0; i<MAX_MOVES && m_Moves[i].x != NONE; i++)
{
Ellipse(hdc,(m_Moves[i].x - WALL_SIZE) *SQUARE_SIZE + 15,
(m_Moves[i].y - WALL_SIZE) *SQUARE_SIZE + 15,
(m_Moves[i].x - WALL_SIZE) *SQUARE_SIZE + 25,
(m_Moves[i].y - WALL_SIZE) *SQUARE_SIZE + 25);
}
DeleteObject(white);
}
//--------------------------------------------------------------------------
// TempDraw
// --------
// General : Draws the checkers on the board from the temporary
// copy of the checkers arrays
// Parameters : HDC (device context)
// Return Value : None
//--------------------------------------------------------------------------
void CPlay::TempDraw(HDC &hdc)
{
int i;
CHECKERS brushFlag = REDCHECKER;
//creating brushes for coloring
HBRUSH red,blue;
red = CreateSolidBrush(RGB(200,30,30));
blue = CreateSolidBrush(RGB(80,80,250));
SelectObject(hdc,red);
for(i = 0; i<MAX_CHECKERS; i++)
{
if(tempRed[0][i] != REDCHECKER)
{
//draw checker
Ellipse(hdc,(tempRed[0][i]-WALL_SIZE)*SQUARE_SIZE,
(tempRed[1][i]-WALL_SIZE)*SQUARE_SIZE,
SQUARE_SIZE+(tempRed[0][i]-WALL_SIZE)*SQUARE_SIZE,
SQUARE_SIZE+(tempRed[1][i]-WALL_SIZE)*SQUARE_SIZE);
}
if(tempRed[2][i] == REDKING)
{
Ellipse(hdc,(tempRed[0][i]-WALL_SIZE)*SQUARE_SIZE+10,
(tempRed[1][i]-WALL_SIZE)*SQUARE_SIZE+10,
30+(tempRed[0][i]-WALL_SIZE)*SQUARE_SIZE,
30+(tempRed[1][i]-WALL_SIZE)*SQUARE_SIZE);
}
}
SelectObject(hdc,blue);
for(i = 0; i<MAX_CHECKERS; i++)
{
if(tempBlue[0][i] != BLUECHECKER)
{
//draw checker
Ellipse(hdc,(tempBlue[0][i]-WALL_SIZE)*SQUARE_SIZE,
(tempBlue[1][i]-WALL_SIZE)*SQUARE_SIZE,
SQUARE_SIZE+(tempBlue[0][i]-WALL_SIZE)*SQUARE_SIZE,
SQUARE_SIZE+(tempBlue[1][i]-WALL_SIZE)*SQUARE_SIZE);
}
if(tempBlue[2][i] == BLUEKING)
{
Ellipse(hdc,(tempBlue[0][i]-WALL_SIZE)*SQUARE_SIZE+10,
(tempBlue[1][i]-WALL_SIZE)*SQUARE_SIZE+10,
30+(tempBlue[0][i]-WALL_SIZE)*SQUARE_SIZE,
30+(tempBlue[1][i]-WALL_SIZE)*SQUARE_SIZE);
}
}
DeleteObject(red);
DeleteObject(blue);
}
//--------------------------------------------------------------------------
// ClearPossibleMoves
// ------------------
// General : Clears from screen the possible moves
// Parameters : opp1 - hWnd (handle to window)
// Return Value : None
//--------------------------------------------------------------------------
void CPlay::ClearPossibleMoves(HWND &hWnd)
{
RECT rect;
for (int i = 0; i<MAX_MOVES && m_Moves[i].x != NONE; i++)
{
rect.left = (m_Moves[i].x - WALL_SIZE) * SQUARE_SIZE + 15;
rect.right = (m_Moves[i].x - WALL_SIZE) * SQUARE_SIZE + 25;
rect.bottom = (m_Moves[i].y - WALL_SIZE) * SQUARE_SIZE + 25;
rect.top = (m_Moves[i].y - WALL_SIZE) * SQUARE_SIZE + 15;
InvalidateRect(hWnd,&rect,false);
}
}
//--------------------------------------------------------------------------
// ActivateChecker
// ---------------
// General : Runs checks in order to determine if
// a checker the user wants to select is
// able to make a move
// Parameters : opp1 - x coordinate of chosen checker
// opp2 - y coordinate of chosen checker
// opp3 - HDC (device context)
// Return Value : Possible to move this checker or not
//--------------------------------------------------------------------------
int CPlay::ActivateChecker(int x, int y, HDC &hdc,HWND &hWnd)
{
//increasing to match the game board
x = x + WALL_SIZE;
y = y + WALL_SIZE;
ClearPossibleMoves(hWnd);
ClearPossibleMoves();
int Moving = 0;
if(m_MustJump == 1)
Moving = CheckJump(x,y,true);
else
Moving = CheckMove(x,y,true);
if(Moving)
{
//draws moves possibilites
DrawPossibleMoves(hdc);
//creates brushes for coloring
HBRUSH red,blue;
red = CreateSolidBrush(RGB(200,130,130));
blue = CreateSolidBrush(RGB(180,180,250));
//choosing color
if(m_Board[y][x]==REDCHECKER || m_Board[y][x]==REDKING)
SelectObject(hdc,red);
else SelectObject(hdc,blue);
//drawing the checker
Ellipse(hdc,(x - WALL_SIZE)*SQUARE_SIZE,(y - WALL_SIZE)*SQUARE_SIZE,
SQUARE_SIZE + (x - WALL_SIZE)*SQUARE_SIZE,
SQUARE_SIZE + (y - WALL_SIZE)*SQUARE_SIZE);
DeleteObject(red);
DeleteObject(blue);
m_Active.x = x;
m_Active.y = y;
return Moving;
}
return Moving;
}
//--------------------------------------------------------------------------
// MoveToPoint
// -----------
// General : Checks if active target can move to the
// given target, and moves the checker
// there if its true
// Parameters : opp1 - x coordinate of chosen target
// opp2 - y coordinate of chosen target
// opp3 - must jump in this turn or not
// opp4 - handle to window
// Return Value : Moved to the target point or not
//--------------------------------------------------------------------------
MoveType CPlay::MoveToPoint(int destX, int destY,HDC &hdc,HWND &hWnd,bool pc)
{
MoveType moved = NOMOVE;
//increasing to match the game board
if(!pc)
{
destY = destY + WALL_SIZE;
destX = destX + WALL_SIZE;
}
if(pc || IsPossibleMove(destX,destY)) //checks if possible to move
{
ClearPossibleMoves(hWnd);
//moves the checker
if( (destY == WALL_SIZE && m_Board[m_Active.y][m_Active.x] == BLUECHECKER) ||
(destY == GAMEBOARD_SIZE - WALL_SIZE - 1 &&
m_Board[m_Active.y][m_Active.x] == REDCHECKER) )
m_Board[destY][destX] = m_Board[m_Active.y][m_Active.x]*2;
else
m_Board[destY][destX] = m_Board[m_Active.y][m_Active.x];
m_Board[m_Active.y][m_Active.x] = EMPTY;
MoveCheckerPt(m_Turn,m_Active.x,m_Active.y,destX,destY);
moved = MOVE;
if (m_MustJump !=0) //jump was made
{
//captured checker = 0
m_Board[m_Active.y + (destY - m_Active.y)/2]
[m_Active.x + (destX - m_Active.x)/2] = EMPTY;
MoveCheckerPt(-m_Turn, m_Active.x + (destX - m_Active.x)/2,
m_Active.y + (destY - m_Active.y)/2,-1,-1);
moved = JUMP;
}
ClearPossibleMoves();
if(!pc && m_MustJump)
{
//checks for more possible moves
m_MustJump = CheckJump(destX,destY,true);
if(m_MustJump)
{
moved = MULTIJUMP;
m_Active.x = destX;
m_Active.y = destY;
DrawPossibleMoves(hdc);
}
}
else
{
m_Active.x = NONE;
m_Active.y = NONE;
}
}
return moved;
}
//--------------------------------------------------------------------------
// CheckMove
// ---------
// General : Checks in which directions can a checker
// in given coordinats move
// Parameters : opp1 - x coordinate of checker
// opp2 - y coordinate of checker
// WriteMove - possible moves array should
// be updated or not
// Return Value : Checker can be moved or not
//--------------------------------------------------------------------------
int CPlay::CheckMove(int x, int y, bool WriteMove)
{
int move = 0;
int P = 0;
int direction = m_Board[y][x] - m_Board[y][x]/2;
POINT moves[4] = { x-1, y+direction, x+1, y+direction, x+1, y-direction,
x-1, y-direction };
for(int i = 0; i<MAX_MOVES; i++)
{
if((i<2 || abs(m_Board[y][x]) == KING) &&
m_Board[moves[i].y][moves[i].x] == 0)
{
if(WriteMove)
{
m_Moves[P].x = moves[i].x;
m_Moves[P++].y = moves[i].y;
}
move = 1;
}
}
return move;
}
//--------------------------------------------------------------------------
// CheckJump
// ---------
// General : Checks in which directions can a checker
// in given coordinats Jump
// Parameters : opp1 - x coordinate of checker
// opp2 - y coordinate of checker
// Return Value : Checker can jump or not
//--------------------------------------------------------------------------
int CPlay::CheckJump(int x, int y, bool save)
{
int jump = 0;
int P = 0;
int dir = m_Board[y][x] - m_Board[y][x]/2;
POINT moves[4] = {x-2,y+dir*2,x+2,y+dir*2,x-2,y-dir*2,x+2,y-dir*2};
POINT opposite[4] = {x-1,y+dir,x+1,y+dir,x-1,y-dir,x+1,y-dir};
for (int i = 0; i<MAX_MOVES; i++)
{
if((i<2 || abs(m_Board[y][x]) == KING) &&
m_Board[moves[i].y][moves[i].x] == EMPTY &&
OppositeCheckers(x,y,opposite[i].x,opposite[i].y))
{
if(save)
{
m_Moves[P].x = moves[i].x;
m_Moves[P++].y = moves[i].y;
}
jump = 1;
}
}
return jump;
}
//--------------------------------------------------------------------------
// OppositeCheckers
// ----------------
// General : Checks if the two given checkers are
// from different players
// Parameters : opp1 - x coordinate of checker 1
// opp2 - y coordinate of checker 1
// : opp3 - x coordinate of checker 2
// opp4 - y coordinate of checker 2
// Return Value : Checkers are opposite or not
//--------------------------------------------------------------------------
bool CPlay::OppositeCheckers(int x1,int y1,int x2,int y2)
{
//if one of these spotes isnt checker
if (m_Board[y1][x1] * m_Board[y2][x2] == 0)
return false;
//if checkers are checkers and they are different
if( (m_Board[y1][x1] - m_Board[y1][x1]/2) !=
(m_Board[y2][x2] - m_Board[y2][x2]/2))
return true;
return false;
}
//--------------------------------------------------------------------------
// IsPossibleMove
// --------------
// General : Checks if a target point is in moves list
// Parameters : opp1 - x coordinate of target
// opp2 - y coordinate of target
// Return Value : Target in possible moves list or not
//--------------------------------------------------------------------------
bool CPlay::IsPossibleMove(int destX, int destY)
{
for(int i = 0; i<MAX_MOVES && m_Moves[i].x != NONE; i++)
if(m_Moves[i].x == destX && m_Moves[i].y == destY)
return true;
return false;
}
//--------------------------------------------------------------------------
// CheckMustJump
// -------------
// General : Checks if in current turn there has to
// be jump made by checker
// Parameters : opp1 - Type of checker(red or blue)
// Return Value : Must be a jump or not
//--------------------------------------------------------------------------
bool CPlay::CheckMustJump(int CheckerType)
{
int x,y;
for (y = WALL_SIZE; y<BOARD_SIZE + WALL_SIZE; y++)
for (x = WALL_SIZE; x<BOARD_SIZE + WALL_SIZE; x++)
if( (m_Board[y][x] == CheckerType || m_Board[y][x] == CheckerType*2)
&& CheckJump(x,y,false)!=0)
{
m_MustJump = 1;
return true;
}
m_MustJump = 0;
return false;
}
//--------------------------------------------------------------------------
// NowhereToMove
// -------------
// General : Checks if a player cannot move any of
// his checkers which are left (lose case)
// Parameters : opp1 - Type of checker(red or blue)
// Return Value : Possible to move a checker or not
//--------------------------------------------------------------------------
bool CPlay::NowhereToMove(int CheckerType)
{
int x,y;
for (y = WALL_SIZE; y<BOARD_SIZE + WALL_SIZE; y++)
for (x = WALL_SIZE; x<BOARD_SIZE + WALL_SIZE; x++)
if( (m_Board[y][x] == CheckerType || m_Board[y][x] == CheckerType*2)
&& (CheckMove(x,y,false)!=0 || CheckJump(x,y,false)!=0))
return false;
return true;
}
//--------------------------------------------------------------------------
// MoveCheckerPt
// -------------
// General : moves checker's coordinats in array of checkers
// or puts -1 in coordinats of those which are needed
// to be erased
// Parameters : opp1 - Type of checker(red or blue)
// opp2 - X coordinat of checker
// opp3 - Y coordinat of checker
// opp4 - X destination coordinat
// opp5 - Y destination coordinat
// Return Value : the index of the movied checker in the checkers array
//--------------------------------------------------------------------------
int CPlay::MoveCheckerPt(int type, int x, int y,int destX,int destY)
{
POINT *loop;
//choose the right array (red or blue checkers)
if(type == RED)
loop = pRedCheckers;
else
loop = pBlueCheckers;
//go through the array
for (int i = 0; i<MAX_CHECKERS; i++)
{
if(loop[i].x == x && loop[i].y == y) // if found
{
loop[i].x = destX;
loop[i].y = destY;
return i;
}
}
return -1;
}
//--------------------------------------------------------------------------
// MoveCheckerPt
// -------------
// General : moves checker's coordinats in array of checkers
// or puts -1 in coordinats of those which are needed
// to be erased
// Parameters : opp1 - Type of checker(red or blue)
// opp2 - index in checkers array
// opp3 - X destination coordinat
// opp4 - Y destination coordinat
// Return Value : None
//--------------------------------------------------------------------------
void CPlay::MoveCheckerPt(int type, int i, int x, int y)
{
POINT *loop;
//choose the right array (red or blue checkers)
if(type == RED)
loop = pRedCheckers;
else
loop = pBlueCheckers;
loop[i].x = x;
loop[i].y = y;
}
//--------------------------------------------------------------------------
// CopyArrays
// ----------
// General : Makes a copt of the checkers arrays
// Parameters : None
// Return Value : None
//--------------------------------------------------------------------------
void CPlay::CopyArrays()
{
for (int i = 0; i<MAX_CHECKERS; i++)
{
tempRed[0][i] = pRedCheckers[i].x;
tempRed[1][i] = pRedCheckers[i].y;
tempRed[2][i] = m_Board[pRedCheckers[i].y][pRedCheckers[i].x];
tempBlue[0][i] = pBlueCheckers[i].x;
tempBlue[1][i] = pBlueCheckers[i].y;
tempBlue[2][i] = m_Board[pBlueCheckers[i].y][pBlueCheckers[i].x];
}
}
//--------------------------------------------------------------------------
// PCMoveToPoint
// -------------
// General : moves the checker turn made by computer
// Parameters : opp1 - X destination coordinat
// opp2 - Y destination coordinat
// Return Value : Moved to the target point or not
//--------------------------------------------------------------------------
int CPlay::PCMoveToPoint(CMovesNode* node,HWND &hWnd)
{
int moved;
int destX,destY,x,y;
HDC hdc = GetDC(hWnd);
moved = 0;
int jump = CheckMustJump(RED);
while(node)
{
node->GetCoordinats(x,y,destX,destY);
m_Active.x = x; m_Active.y = y;
MoveToPoint(destX,destY,hdc,hWnd,true);
InvalidateGameRect(destX - 2,destY - 2);
InvalidateGameRect(x - 2,y - 2);
if(jump != 0)
{
InvalidateGameRect(x + (destX - x)/2 - 2,
y + (destY - y)/2 - 2);
numBlueCheckers++;
}
node = node->GetNext();
}
ReleaseDC(hWnd,hdc);
return moved;
}