This repository has been archived by the owner on Jul 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmainAux.c
71 lines (66 loc) · 2.13 KB
/
mainAux.c
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "mainAux.h"
/* for testing */
void printCallingFunc(char *functionName) {
printf("Calling %s\n", functionName);
}
/* reads next command from user using getCommandFromUser and invokes the relevant function from "commands.h"
* return value: FALSE (0) if user enters EXIT or completes the board, TRUE (1) otherwise (game continues)*/
int playTurn(gameParams *game) {
commandStruct *commandToPlay = getCommandFromUser(game);
enum commandType type;
if (commandToPlay->isValid == TRUE) {
type = commandToPlay->type;
switch (type) {
case SET:
set(commandToPlay->x, commandToPlay->y, commandToPlay->z, game);
break;
case HINT:
hint(commandToPlay->x, commandToPlay->y, game);
break;
case VALIDATE:
validate(game);
break;
case RESET:
reset(game);
break;
case EXIT:
freeCommand(commandToPlay);
exitGame(game);
return FALSE;
case SOLVE:
solve(game, commandToPlay->fileName);
break;
case EDIT:
edit(game, commandToPlay->fileName);
break;
case MARK_ERRORS:
mark_errors(game, commandToPlay->markErrors);
break;
case PRINT_BOARD:
printBoard(game);
break;
case GENERATE:
generate(game, commandToPlay->x, commandToPlay->y);
break;
case UNDO:
undo(game);
break;
case REDO:
redo(game);
break;
case SAVE:
save(game, commandToPlay->fileName);
break;
case NUM_SOLS:
numSolutions(game);
break;
case AUTO_FILL:
autoFill(game);
break;
default:
printErrorInCodeFlow("playTurn", "parser.c");
}
}
freeCommand(commandToPlay);
return TRUE;
}