-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
65 lines (58 loc) · 2.27 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
60
61
62
63
64
65
/*
* main.c
*
* Created on: 10 Mar 2017
* Author: Declan
*/
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include "changingValues.h"
#include "game.h"
/* These variables are called as global to make them readily available to all functions without having to declare them in the
prototypes of a large number of functions */
int num_players, num_slots;
int main(){
setbuf(stdout, NULL);
/*Ask the user to input how many players are playing the game and store it
in the variable num_players*/
printf("How many players would you like to input (max 6): ");
scanf("%d", &num_players);
/*If the user inputs a number greater than the maximum number of players then
tell them that there was an error and ask them to input the number again.*/
while(num_players>6){
printf("\nYou can only have a maximum of 6 players. Try again.");
printf("\nHow many players would you like to input (max 6): ");
scanf("%d", &num_players);
}
/*Creating a array named players of size num_players and it is of type struct
player.*/
struct player players[num_players];
/*Call function to generate the list of players*/
playersFromUser(players);
/*Ask the user how many slots are to be generated*/
printf("How many slots would you like to input (max 20): ");
scanf("%d", &num_slots);
/*Produce an error if the input number is greater than 20 or less than the number of players*/
while (num_slots <= num_players || num_slots > 20){
if (num_slots > 20){
printf("You cannot create more than 20 slots. Please choose a different number.\n");
printf("How many slots would you like to input (max 20): ");
scanf("%d", &num_slots);
}
else if (num_slots <= num_players){
printf("How do you plan to squeeze %d players on %d slots?\n", num_players, num_slots);
printf("How many slots would you like to input (max 20): ");
scanf("%d", &num_slots);
}
}
/*Create array of size num_slots and type enum slot_types to store slots*/
struct slot slots[num_slots];
/*Call function to generate list of slots*/
slotsFromUser(slots);
/*Call function to populate the board*/
populateBoard(players, slots);
runGame(players, slots, num_players, num_slots);
return 0;
}