-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsoleMain.c
More file actions
40 lines (37 loc) · 795 Bytes
/
Copy pathConsoleMain.c
File metadata and controls
40 lines (37 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* main.c
*
* Created on: Feb 25, 2018
* Author: krimolovsky
*/
#include "ConsoleMain.h"
int consoleMain() {
ChessGame* game;
int error_check=0;
printf(" Chess\n-------\n");
game=createChessGame();
game=ChessMainSettings(game);
if(game==NULL){
printf("Error: Could not create a new game. Exiting...\n");
return 0;
}
while(1){
if(game->game_mode==1 && game->currentPlayer!=game->user_color){//if computer's turn
error_check=computerMoveChess(game);
if (error_check==0) {
printf("Error: Could not calculate computer's move. Exiting...\n");
destoryChessGame(game);
return 0;
}
}
else{
game=inGamePlayerCommandsAux(game);
}
checkThreatenedAux(game);
if(isGameOverAux(game)){
destoryChessGame(game);
return 0;
}
}
return 0;
}