Advertisement
Guest User

Untitled

a guest
Dec 15th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. void PROMOTION_B()
  2. {
  3. char c;
  4. printf("this pawn will be promoted please enter the piece 'q for queen ,k for knight,b for bishop,r for rook");
  5. scanf("%c",&c);
  6. switch (c){
  7. case 'q':board[x][y]=&queen_b;break;
  8. case 'k':board[x][y]=&knight_b;break;
  9. case 'r':board[x][y]=&rook_b;break;
  10. case 'b':board[x][y]=&bishop_b;break;
  11. default: printf("ERRROR ! Promotion is not valid try again.");PROMOTION_B();
  12. }
  13. }
  14.  
  15. void PAWN_B(int i, int j,int x, int y){
  16. if (board[x][y]==&rook_b || board[x][y]==&knight_b || board[x][y]==&bishop_b || board[x][y]==&king_b || board[x][y]==&queen_b || board[x][y]==&pawn_b){
  17. printf("ERRROR ! Move is not valid try again.");
  18. SCAN_B;
  19. }
  20. else {
  21. if (x==i+1&&y==j&&(board[x][y]==&block_b || board[x][y]==&block_w )){
  22. if (i==7){
  23. PROMOTION_B();
  24.  
  25. }else {
  26. board[x][y]=&pawn_b;
  27. BLACK_OR_WHITE(i,j);
  28. EB(i,j,W);
  29. printBoard();
  30. }
  31. }
  32. else if (((x==i+1&&y==j+1)||(x==i+1&&y==j-1))&&(board[x][y]==&rook_w || board[x][y]==&knight_w ||
  33. board[x][y]==&bishop_w || board[x][y]==&king_w || board[x][y]==&queen_w || board[x][y]==&pawn_w)){
  34. board[x][y]=&pawn_b;
  35. BLACK_OR_WHITE(i,j);
  36. EB(i,j,W);
  37. printBoard();
  38. }
  39. else if (x==i+2&&y==j&&i==1&&(board[x][y]==&block_b || board[x][y]==&block_w )&&(board[x-1][y]==&block_b || board[x-1][y]==&block_w )){
  40. board[x][y]=&pawn_b;
  41. BLACK_OR_WHITE(i,j);
  42. EB(i,j,W);
  43. printBoard();
  44. }
  45.  
  46. else {
  47. printf("ERRROR ! Move is not valid try again.");
  48. SCAN_B();
  49. }
  50. }
  51. }
  52. void PROMOTION_W()
  53. {
  54. char c;
  55. printf("this pawn will be promoted please enter the piece 'q for queen ,k for knight,b for bishop,r for rook");
  56. scanf("%c",&c);
  57. switch (c){
  58. case 'q':board[x][y]=&queen_w;break;
  59. case 'k':board[x][y]=&knight_w;break;
  60. case 'r':board[x][y]=&rook_w;break;
  61. case 'b':board[x][y]=&bishop_w;break;
  62. default: printf("ERRROR ! Promotion is not valid try again.");PROMOTION_W();
  63. }
  64. }
  65.  
  66. void PAWN_W(int i, int j,int x, int y){
  67. if (board[x][y]==&rook_w || board[x][y]==&knight_w || board[x][y]==&bishop_w || board[x][y]==&king_w || board[x][y]==&queen_w || board[x][y]==&pawn_w){
  68. printf("ERRROR ! Move is not valid try again.");
  69. SCAN_W();
  70. }
  71. else {
  72. if (x==i-1&&y==j&&(board[x][y]==&block_b || board[x][y]==&block_w )){
  73. if (i==0){
  74. PROMOTION_W();
  75.  
  76. }else {
  77. board[x][y]=&pawn_w;
  78. BLACK_OR_WHITE(i,j);
  79. EB(i,j,B);
  80. printBoard();
  81. }
  82. }
  83. else if (((x==i-1&&y==j+1)||(x==i-1&&y==j-1))&&(board[x][y]==&rook_b || board[x][y]==&knight_b ||
  84. board[x][y]==&bishop_b || board[x][y]==&king_b || board[x][y]==&queen_b || board[x][y]==&pawn_b)){
  85. board[x][y]=&pawn_w;
  86. BLACK_OR_WHITE(i,j);
  87. EB(i,j,B);
  88. printBoard();
  89. }
  90. else if (x==i-2&&y==j&&i==6&&(board[x][y]==&block_b || board[x][y]==&block_w )&&(board[x+1][y]==&block_b || board[x+1][y]==&block_w )){
  91. board[x][y]=&pawn_w;
  92. BLACK_OR_WHITE(i,j);
  93. EB(i,j,B);
  94. printBoard();
  95. }
  96.  
  97. else {
  98. printf("ERRROR ! Move is not valid try again.");
  99. SCAN_W();
  100. }
  101. }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement