Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void check_mate(void)
- {
- int i,j,k,q;
- if (turn==1){
- printf("Your King is checked by player 2!\n");
- for( i=kp1i-1; i<=kp1i+1; i++)
- {
- for(j=kp1j-1; j<=kp1j+1; j++){
- if(!checkedby2[i+1][j+1] && occupied[i][j]!=1 && (i<8 && i>=0 && j>=0 && j<8 ))
- {
- printf("Move your king or a piece to end the check\n");
- movement();
- set1();
- set2();
- set_checks1();
- set_checks2();
- if(checkedby2[kp1i+1][kp1j+1]){
- do
- {
- printf("Incorrect move(doesn't end the check),Please Enter another move.\n");
- switch_turns();
- undo();
- switch_turns();
- set1();
- set2();
- set_checks1();
- set_checks2();
- movement();
- set1();
- set2();
- set_checks1();
- set_checks2();
- }while(checkedby2[kp1i+1][kp1j+1]);
- }return;
- }
- }
- }
- for(i=0;i<ROWS;i++)
- {
- for(j=0;j<COLUMNS;j++)
- {
- if(movability1[i][j]==1 && zone1[i][j]==1)
- {
- printf("Move a piece to end the check\n");
- movement();
- set1();
- set2();
- set_checks1();
- set_checks2();
- if(checkedby1[kp2i+1][kp2j+1]){
- do
- {
- printf("Incorrect move(doesn't end the check),Please Enter another move.\n");
- switch_turns();
- undo();
- switch_turns();
- set1();
- set2();
- set_checks1();
- set_checks2();
- movement();
- set1();
- set2();
- set_checks1();
- set_checks2();
- }while(checkedby2[kp1i+1][kp1j+1]);
- }
- }return;
- }
- }
- end_game();
- }
- else
- {
- printf("\nYour King is checked by player 1!\n");
- for( i=kp2i-1; i<=kp2i+1; i++)
- {
- for(j=kp2j-1; j<=kp2j+1; j++){
- if(!checkedby1[i+1][j+1] && occupied[i][j]!=1 && (i<8 && i>=0 && j>=0 && j<8 ))
- {
- printf("Move your king or a piece to end the check\n");
- movement();
- set1();
- set2();
- set_checks1();
- set_checks2();
- if(checkedby1[kp2i+1][kp2j+1]){
- do
- {
- printf("Incorrect move(doesn't end the check),Please Enter another move.\n");
- switch_turns();
- undo();
- switch_turns();
- set1();
- set2();
- set_checks1();
- set_checks2();
- movement();
- set1();
- set2();
- set_checks1();
- set_checks2();
- }while(checkedby1[kp2i+1][kp2j+1]);
- }return;
- }
- }
- }
- for(i=0;i<ROWS;i++)
- {
- for(j=0;j<COLUMNS;j++)
- {
- if(movability2[i][j]==1 && zone2[i][j]==1)
- {
- printf("Move a piece to end the check");
- movement();
- set1();
- set2();
- set_checks1();
- set_checks2();
- if(checkedby1[kp2i+1][kp2j+1]){
- counter_steps2--;
- do
- {
- printf("Incorrect move(doesn't end the check),Please Enter another move.\n");
- switch_turns();
- undo();
- switch_turns();
- set1();
- set2();
- set_checks1();
- set_checks2();
- movement();
- set1();
- set2();
- set_checks1();
- set_checks2();
- }while(checkedby1[kp2i+1][kp2j+1]);
- }return;
- }
- }
- }
- end_game();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement