Advertisement
anas_harby

Untitled

Dec 22nd, 2015
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.28 KB | None | 0 0
  1. void userInput(char inp[1000])
  2. {
  3.  
  4.  
  5.     if((strcmp("undo",inp) == 0)) {
  6.         if(turn==1) {
  7.             printf("You Can't Undo More!\n");
  8.             getInput();
  9.         }
  10.         int iC,iD,jC,jD;
  11.         movesCount--;
  12.         iC = undo[movesCount]/1000;
  13.         iD = undo[movesCount]/100%10;
  14.         jC = undo[movesCount]/10%10;
  15.         jD = undo[movesCount]%10;
  16.         move(iD, iC, jD, jC);
  17.         findKings();
  18.         correspondPrototypeBoard();
  19.         turn-=2;
  20.  
  21.  
  22.     }
  23.     else {
  24.         while(strlen(inp)!=4)
  25.         {
  26.             printf("Invalid Input!\n");
  27.             getInput();
  28.         }
  29.         int iCurrent, iDestination, jCurrent, jDestination;
  30.         jCurrent = (int)inp[0] - (int)'A';
  31.         iCurrent = (int)inp[1] - (int)'0';
  32.         jDestination = (int)inp[2] - (int)'A';
  33.         iDestination = (int)inp[3] - (int)'0';
  34.         iDestination = 8 - iDestination;
  35.         iCurrent = 8 - iCurrent;
  36.  
  37.  
  38.  
  39.         if(turn%2!=0 && (piecesBoard[iCurrent][jCurrent]>='A' && piecesBoard[iCurrent][jCurrent]<='Z'))
  40.         {
  41.             printf("White Pieces Turn!\n");
  42.             getInput();
  43.         }
  44.  
  45.         else if(turn%2==0 && (piecesBoard[iCurrent][jCurrent]>='a' && piecesBoard[iCurrent][jCurrent]<='z'))
  46.         {
  47.             printf("Black Pieces Turn!\n");
  48.             getInput();
  49.         }
  50.  
  51.         else if(validate(iCurrent, iDestination, jCurrent, jDestination)!=0)
  52.         {
  53.             printErrors(validate(iCurrent, iDestination, jCurrent, jDestination), iCurrent, iDestination, jCurrent, jDestination);
  54.             getInput();
  55.  
  56.         }
  57.  
  58.  
  59.  
  60.         else if(validateCheck(iCurrent,iDestination,jCurrent,jDestination)==1)
  61.         {
  62.             if(turn%2==1)
  63.                 printf("WHITE KING WILL BE CHECKED!\n");
  64.             else if(turn%2==0)
  65.                 printf("BLACK KING WILL BE CHECKED!\n");
  66.             getInput();
  67.         }
  68.  
  69.         else if(validate(iCurrent, iDestination, jCurrent, jDestination)==0)
  70.         {
  71.  
  72.             capture(iCurrent, iDestination, jCurrent, jDestination);
  73.             trackUndo();
  74.             move(iCurrent, iDestination, jCurrent, jDestination);
  75.             findKings();
  76.             correspondPrototypeBoard();
  77.             stalemate();
  78.             checkmate();
  79.  
  80.  
  81.  
  82.         }
  83.     }
  84.  
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement