|
@ -12,5 +12,28 @@ bool istzugerlaubt_Dame(char** Brett, int startX, int startY, int endX, int endY |
|
|
if (endX < 0 || endX >= 8 || endY < 0 || endY >= 8) |
|
|
if (endX < 0 || endX >= 8 || endY < 0 || endY >= 8) |
|
|
return false; |
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int dx = abs(endX - startX); |
|
|
|
|
|
int dy = abs(endY - startY); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dx != 0 && dy != 0 && dx != dy) |
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dx > 0) { |
|
|
|
|
|
int dirX = (endX - startX) / dx; |
|
|
|
|
|
for (int i = 1; i < dx; i++) { |
|
|
|
|
|
if (Brett[startY + i * dirX][startX + i * dirX] != ' ') |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (dy > 0) { |
|
|
|
|
|
int dirY = (endY - startY) / dy; |
|
|
|
|
|
for (int i = 1; i < dy; i++) { |
|
|
|
|
|
if (Brett[startY + i * dirY][startX + i * dirY] != ' ') |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |