Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void PROMOTION_B()
- {
- char c;
- printf("this pawn will be promoted please enter the piece 'q for queen ,k for knight,b for bishop,r for rook");
- scanf("%c",&c);
- switch (c){
- case 'q':board[x][y]=&queen_b;break;
- case 'k':board[x][y]=&knight_b;break;
- case 'r':board[x][y]=&rook_b;break;
- case 'b':board[x][y]=&bishop_b;break;
- default: printf("ERRROR ! Promotion is not valid try again.");PROMOTION_B();
- }
- }
- void PAWN_B(int i, int j,int x, int y){
- 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){
- printf("ERRROR ! Move is not valid try again.");
- SCAN_B;
- }
- else {
- if (x==i+1&&y==j&&(board[x][y]==&block_b || board[x][y]==&block_w )){
- if (i==7){
- PROMOTION_B();
- }else {
- board[x][y]=&pawn_b;
- BLACK_OR_WHITE(i,j);
- EB(i,j,W);
- printBoard();
- }
- }
- else if (((x==i+1&&y==j+1)||(x==i+1&&y==j-1))&&(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)){
- board[x][y]=&pawn_b;
- BLACK_OR_WHITE(i,j);
- EB(i,j,W);
- printBoard();
- }
- 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 )){
- board[x][y]=&pawn_b;
- BLACK_OR_WHITE(i,j);
- EB(i,j,W);
- printBoard();
- }
- else {
- printf("ERRROR ! Move is not valid try again.");
- SCAN_B();
- }
- }
- }
- void PROMOTION_W()
- {
- char c;
- printf("this pawn will be promoted please enter the piece 'q for queen ,k for knight,b for bishop,r for rook");
- scanf("%c",&c);
- switch (c){
- case 'q':board[x][y]=&queen_w;break;
- case 'k':board[x][y]=&knight_w;break;
- case 'r':board[x][y]=&rook_w;break;
- case 'b':board[x][y]=&bishop_w;break;
- default: printf("ERRROR ! Promotion is not valid try again.");PROMOTION_W();
- }
- }
- void PAWN_W(int i, int j,int x, int y){
- 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){
- printf("ERRROR ! Move is not valid try again.");
- SCAN_W();
- }
- else {
- if (x==i-1&&y==j&&(board[x][y]==&block_b || board[x][y]==&block_w )){
- if (i==0){
- PROMOTION_W();
- }else {
- board[x][y]=&pawn_w;
- BLACK_OR_WHITE(i,j);
- EB(i,j,B);
- printBoard();
- }
- }
- else if (((x==i-1&&y==j+1)||(x==i-1&&y==j-1))&&(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)){
- board[x][y]=&pawn_w;
- BLACK_OR_WHITE(i,j);
- EB(i,j,B);
- printBoard();
- }
- 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 )){
- board[x][y]=&pawn_w;
- BLACK_OR_WHITE(i,j);
- EB(i,j,B);
- printBoard();
- }
- else {
- printf("ERRROR ! Move is not valid try again.");
- SCAN_W();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement