forked from lakshyajain-0291/Text-based-Adventure-Game-in-C
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
59 lines (48 loc) · 1.62 KB
/
main.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
#include "ICS_Project.h"
// #include"cJSON.c"
int state;
int main()
{
printf("\e[1;1H\e[2J");
char *playerID = (char *)malloc(sizeof(char) * MAX_PLAYER_ID_LENGTH);
if (playerID == NULL)
{
fprintf(stderr, "Memory allocation failed\n");
return EXIT_FAILURE;
}
Player *player = NULL;
// printRules();
printf("\nEnter Login ID : ");
if (scanf("%s", playerID) != 1)
{
fprintf(stderr, "Error reading player ID\n");
free(playerID);
return EXIT_FAILURE;
}
player = gameInitializer(playerID);
if (player == NULL)
{
fprintf(stderr, "Failed to initialize player\n");
free(playerID);
return EXIT_FAILURE;
}
printf("\nid-%s",player->id);
// printf("\nname-%s",player->name);
// printf("\nlevel-%d",player->level);
// printf("\nstats,hp-%d",player->stats->HP);
// printf("\ninventory,items[0]-%s",player->inventory->items[0]);
// printf("\ninventory,aitems[0]-%d",player->inventory->activeItems[0]);
// printf("\ngold-%d",player->gold);
// printf("\ncur_loc-%s",player->currentLocation);
// printf("\nact_que[0]-%s",player->activeQuests[0]);
// printf("\nnpcInfo[0][0]-%d",player->NPCInfo[0][0]);
// printPrologue();
selectState(&state); // function that can be called from anywhere by player to choose a state
while (state >= 0)
processState(player, &state); // function that processes the state
printf("Thank you for playing The Vindication"); /// EXIT STATEMENT
savePlayerData(player);
// // Cleanup
// freePlayer(playerID);
// return EXIT_SUCCESS;
}