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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
int main(void)
{
FILE* input_file;
int zombie_initiative=0, zombie_numbers=0, survivor_numbers, flee=0;
int menu=0, count, count_rows=0, count_columns=0, zombie_count=0, survivor_count=0, end_of_file, initiative_count;
char input_text[100];
double zombie[] = {10, 1, 50, 0, 7, 1, 3, 0};
double george[] = {20, 1, 50, 3, 5, 0, 3, 5};
/* Pre-combat initialisation */
printf("Performing pre-combat initialisation, please stand by.\n------------------------------------------------------\n");
zombie_numbers=1; /* Defines how many zombies there are in this group. For the purpose of this example, it's already been set */
survivor_numbers=1; /* Defines how many survivors fight. Also set for the example. */
srand(time(NULL));
for(count=0; count<zombie_numbers; count++)
{
zombie_initiative = (rand() % 11);
zombie[7] = zombie_initiative;
printf("\nZombie number %d has an initiative of %d.\n\n",zombie_count, zombie_initiative);
zombie_stats(zombie, input_text, zombie_count); /* Prints the list of Zombie stats with table headers */
}
for(count=0; count<survivor_numbers; count++)
survivor_stats(george, input_text, survivor_count); /* Prints the list of Survivor stats with table headers */
printf("Initialisation complete.\n------------------------\n\n");
do{
for(initiative_count=10; initiative_count>-1; initiative_count--)
{
if(george[7]==initiative_count)
{
do{
printf("1. Attack\n2. Flee\n3. Check Current Status\n4. Use Item\n\n");
scanf("%d",&menu);
printf("\n");
switch(menu)
{
case 1:
if(george[0]>0)
survivor_attack(george, zombie);
if(zombie[0]<1)
zombie_numbers--;
break;
case 2:
survivor_numbers--;
flee++;
break;
case 3:
for(count=0; count<zombie_numbers; count++)
zombie_stats(zombie, input_text, zombie_count); /* Prints the list of Zombie stats with table headers */
count=0;
for(count=0; count<survivor_numbers; count++)
survivor_stats(george, input_text, survivor_count); /* Prints the list of Survivor stats with table headers */
break;
case 4:
printf("This has yet to be implemented. Please return from whence ye came.\n\n");
break;
default:
printf("Invalid choice.\n\n");
break;
}
}while(menu==3 || menu==4);
}
else if(zombie[7]==initiative_count)
{
if(zombie[0]>0 && flee==0)
zombie_attack(zombie, george);
if(george[0]<1)
survivor_numbers--;
}
}
}while(zombie_numbers>0 && survivor_numbers>0);
if(zombie_numbers<1)
printf("You have survived another fight.\n");
else if(survivor_numbers<1 && flee==0)
printf("You have been defeated.\n");
else if(zombie_numbers>0 && survivor_numbers<1 && flee!=0)
printf("You manage to escape.\n");
printf("\n");
return 0;
}
|