20 void usage(std::ostream &out,
const char **argv)
23 <<
"Usage: " << argv[0] <<
" [OPTIONS]" << std::endl
25 <<
" A flexible engine for imaginary quartet!" << std::endl
27 <<
"Note:" << std::endl
28 <<
" To ensure an equal distribution of the cards" << std::endl
29 <<
" we enforce: (n * s) mod p == 0." << std::endl
31 <<
"Options:" << std::endl
32 <<
" -s [int] Size of one set. [default: " <<
DEFAULT_SET_SIZE <<
"]" << std::endl
33 <<
" -n [int] Number of sets. [default: " <<
DEFAULT_NUM_SETS <<
"]" << std::endl
35 <<
" -h Show this help and exit." << std::endl;
52 std::cerr << argv[0] <<
": the size of one set has to be at least one" << std::endl;
57 std::cerr << argv[0] <<
": the number of sets has to be at least one" << std::endl;
62 std::cerr << argv[0] <<
": the number of players has to be at least two" << std::endl;
67 std::cerr << argv[0] <<
": enforces (n * s) mod p == 0" << std::endl;
92 while ((opt = getopt(argc, (
char*
const*)argv,
"s:n:p:h")) != -1) {
95 SET_SIZE = atoi(optarg);
98 NUM_SETS = atoi(optarg);
101 NUM_PLAYERS = atoi(optarg);
104 usage(std::cout, argv);
107 usage(std::cerr, argv);
112 Settings settings = {SET_SIZE, NUM_SETS, NUM_PLAYERS};
113 if (!
valid(settings, argv)) {
114 usage(std::cerr, argv);
void usage(std::ostream &out, const char **argv)
Print the usage information for this program on the screen.
bool valid(const Settings &settings, const char **argv)
Validate the settings given.
Settings options(const int argc, const char **argv)
Parse the command line arguments and generate the settings from these.
This file defines the command line argument parsing function header.
This file defines the settings struct.
constexpr int DEFAULT_SET_SIZE
The default value for SET_SIZE.
constexpr int DEFAULT_NUM_SETS
The default value for NUM_SETS.
constexpr int DEFAULT_NUM_PLAYERS
The default value for NUM_PLAYERS.
The settings which characterize a game.
const int NUM_SETS
The number of sets.
const int SET_SIZE
The size of one set, aka the number of cards in one set.
const int NUM_PLAYERS
The number of players playing the game.