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
|
int targets[2][4] = { {target_dw, target_up, target_le, target_ri},
{ row_dw, row_up, col_le, col_ri }};
int i, j, targ_max , i_tar_max;
targ_max = -2;
for ( i = 0; i < 4; i++)
{
for ( j = 0; j < 4; j++)
{
if ( targets[0][i] <= targets[0][j] )
{
targ_max = targets[0][j];
i_tar_max = j;
}
}
}
if ( targ_max > -1 )
{ // this is not finished
if ( i_tar_max <=1 ) // then movement should be on the same column.
{
cout << "\n CRook::move() on column ";
board1.killpiece(rowd, col); // kill the oposing piece
board1.liftpiece(row, col); // take this piece off the board
board1.addpiece(rowd, col, (*this)); // place the piece in place of the attacked piece.
return true;
}
else // movement should be on the same row.
{
cout << "\n CRook::move() on row ";
board1.killpiece(row, cold); // kill the oposing piece
board1.liftpiece(row, col); // take this piece off the board
board1.addpiece(row, cold, (*this)); // place the piece in place of the attacked piece.
return true;
}
}
|