You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.1 KiB

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdbool.h>
  4. #include "spieler.h"
  5. #include "Moving.h"
  6. #include "Turm.h"
  7. bool istzugerlaubt_Turm(char** Brett, int startX, int startY, int endX, int endY, Player player) {
  8. int counter = 0;
  9. if(startX == endX && startY < endY){
  10. counter = endY-startY;
  11. for(int i = 1; i<counter;i++){
  12. if(Brett[startY+i][startX] != ' '){
  13. return false;
  14. }
  15. }
  16. return true;
  17. }else if(startX == endX && startY > endY){
  18. counter = startY-endY;
  19. for(int i = 1; i<counter;i++){
  20. if(Brett[startY-i][startX] != ' '){
  21. return false;
  22. }
  23. }
  24. return true;
  25. }else if(startY == endY && startX<endX){
  26. counter = endX-startX;
  27. for(int i = 1; i<counter;i++){
  28. if(Brett[startY][startX+i] != ' '){
  29. return false;
  30. }
  31. }
  32. return true;
  33. }else if(startY == endY && startX>endX){
  34. counter = startX-endX;
  35. for(int i = 1; i<counter;i++){
  36. if(Brett[startY][startX-i] != ' '){
  37. return false;
  38. }
  39. }
  40. return true;
  41. }else{
  42. return false;
  43. }
  44. }