Skip to content

Commit c71c95d

Browse files
committed
feature: add config and menu
1 parent e4c532d commit c71c95d

File tree

1 file changed

+49
-4
lines changed

1 file changed

+49
-4
lines changed

src/main.c

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,59 @@
22

33
#include <stdio.h>
44
#include <stdlib.h>
5+
#include <string.h>
56

7+
#include "./configuration/main.h"
8+
#include "./macros.h"
9+
#include "./structs.h"
610
#include "./utilities.h"
711

812
int main(const int argsLength, char* args[]) {
9-
// TODO: delete function calls
10-
greetFromSrc();
11-
printf("\n");
12-
greetFromLibs();
13+
Configuration config;
14+
unsigned char error;
15+
16+
Team team;
17+
18+
int userInput;
19+
20+
error = getConfiguration(&config, CONFIGURATION_PATH);
21+
if (error) {
22+
printf("> Error! An error occurred on get the configuration.");
23+
return 1;
24+
};
25+
26+
// reprConfiguration(&config);
27+
// printf("\n");
28+
29+
strcpy(team.name, config.teamName);
30+
31+
printf("> %s team - A Tic-Tac-Toe game developed with C...", DEVELOPMENT_TEAM);
32+
33+
printf("\n\n> Available options:\n\n%s%s%s", " 1 - Play Tic-Tac-Toe.\n", " 2 - Show ranking.\n",
34+
" 0 - Exit.\n");
35+
36+
printf("\n> Select a option: ");
37+
scanf("%d", &userInput);
38+
39+
while (userInput != 0) {
40+
switch (userInput) {
41+
case 1:
42+
printf("\n> Team %s...", team.name);
43+
printf("\n\n> [Playing Tic-Tac-Toe...]");
44+
break;
45+
case 2:
46+
printf("\n> [Showing ranking...]");
47+
break;
48+
default:
49+
printf("\n> [Invalid operation! Try again...]");
50+
};
51+
52+
printf("\n\n> Available options:\n\n%s%s%s", " 1 - Play Tic-Tac-Toe.\n",
53+
" 2 - Show ranking.\n", " 0 - Exit.\n");
54+
55+
printf("\n> Select a option: ");
56+
scanf("%d", &userInput);
57+
};
1358

1459
return 0;
1560
}

0 commit comments

Comments
 (0)