Advertisement
Essam_khames

Untitled

Dec 21st, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.71 KB | None | 0 0
  1. void check_mate(void)
  2. {
  3. int i,j,k,q;
  4. if (turn==1){
  5.  
  6. printf("Your King is checked by player 2!\n");
  7. for( i=kp1i-1; i<=kp1i+1; i++)
  8. {
  9. for(j=kp1j-1; j<=kp1j+1; j++){
  10. if(!checkedby2[i+1][j+1] && occupied[i][j]!=1 && (i<8 && i>=0 && j>=0 && j<8 ))
  11. {
  12. printf("Move your king or a piece to end the check\n");
  13.  
  14. movement();
  15. set1();
  16. set2();
  17. set_checks1();
  18. set_checks2();
  19. if(checkedby2[kp1i+1][kp1j+1]){
  20. do
  21. {
  22. printf("Incorrect move(doesn't end the check),Please Enter another move.\n");
  23. switch_turns();
  24. undo();
  25. switch_turns();
  26. set1();
  27. set2();
  28. set_checks1();
  29. set_checks2();
  30. movement();
  31. set1();
  32. set2();
  33. set_checks1();
  34. set_checks2();
  35. }while(checkedby2[kp1i+1][kp1j+1]);
  36. }return;
  37. }
  38. }
  39. }
  40. for(i=0;i<ROWS;i++)
  41. {
  42. for(j=0;j<COLUMNS;j++)
  43. {
  44. if(movability1[i][j]==1 && zone1[i][j]==1)
  45. {
  46.  
  47. printf("Move a piece to end the check\n");
  48. movement();
  49. set1();
  50. set2();
  51. set_checks1();
  52. set_checks2();
  53. if(checkedby1[kp2i+1][kp2j+1]){
  54. do
  55. {
  56. printf("Incorrect move(doesn't end the check),Please Enter another move.\n");
  57. switch_turns();
  58. undo();
  59. switch_turns();
  60. set1();
  61. set2();
  62. set_checks1();
  63. set_checks2();
  64. movement();
  65. set1();
  66. set2();
  67. set_checks1();
  68. set_checks2();
  69. }while(checkedby2[kp1i+1][kp1j+1]);
  70. }
  71. }return;
  72.  
  73.  
  74. }
  75. }
  76. end_game();
  77.  
  78. }
  79. else
  80. {
  81.  
  82. printf("\nYour King is checked by player 1!\n");
  83. for( i=kp2i-1; i<=kp2i+1; i++)
  84. {
  85. for(j=kp2j-1; j<=kp2j+1; j++){
  86. if(!checkedby1[i+1][j+1] && occupied[i][j]!=1 && (i<8 && i>=0 && j>=0 && j<8 ))
  87. {
  88. printf("Move your king or a piece to end the check\n");
  89.  
  90. movement();
  91. set1();
  92. set2();
  93. set_checks1();
  94. set_checks2();
  95. if(checkedby1[kp2i+1][kp2j+1]){
  96. do
  97. {
  98. printf("Incorrect move(doesn't end the check),Please Enter another move.\n");
  99. switch_turns();
  100. undo();
  101. switch_turns();
  102. set1();
  103. set2();
  104. set_checks1();
  105. set_checks2();
  106. movement();
  107. set1();
  108. set2();
  109. set_checks1();
  110. set_checks2();
  111. }while(checkedby1[kp2i+1][kp2j+1]);
  112. }return;
  113. }
  114. }
  115. }
  116. for(i=0;i<ROWS;i++)
  117. {
  118. for(j=0;j<COLUMNS;j++)
  119. {
  120. if(movability2[i][j]==1 && zone2[i][j]==1)
  121. {
  122. printf("Move a piece to end the check");
  123.  
  124. movement();
  125. set1();
  126. set2();
  127. set_checks1();
  128. set_checks2();
  129. if(checkedby1[kp2i+1][kp2j+1]){
  130. counter_steps2--;
  131. do
  132. {
  133. printf("Incorrect move(doesn't end the check),Please Enter another move.\n");
  134. switch_turns();
  135. undo();
  136. switch_turns();
  137. set1();
  138. set2();
  139. set_checks1();
  140. set_checks2();
  141. movement();
  142. set1();
  143. set2();
  144. set_checks1();
  145. set_checks2();
  146. }while(checkedby1[kp2i+1][kp2j+1]);
  147. }return;
  148. }
  149.  
  150.  
  151. }
  152. }
  153. end_game();
  154. }
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement