Quaternity
main.cpp
Go to the documentation of this file.
1 #include <algorithm>
2 #include <iostream>
3 #include <string>
4 
5 #include "debug.h"
6 #include "input.h"
7 #include "opts.h"
8 #include "settings.h"
9 #include "state.h"
10 #include "update.h"
11 #include "validate.h"
12 
13 int main(int argc, char **argv)
14 {
15  Settings settings = options(argc, (const char**)argv);
16  State state = init_state(settings);
17 
18  std::cout << settings;
19  std::cout << state;
20 
21  while (std::find(state.quartets.begin(), state.quartets.end(), -1) != state.quartets.end()) {
22  bool *valid_answers;
23 
24  // QUESTION
25  Question question;
26  do {
27  question = ask_question();
28  std::cout << question;
29  valid_answers = valid_question(settings, state, question);
30  } while (valid_answers == NULL);
31 
32  // ANSWER
33  Answer answer;
34  do {
35  answer = ask_answer();
36  std::cout << "Answer: " << answer << "." << std::endl;
37  } while (!valid_answers[answer]);
38 
39  // UPDATE STATE
40  update_state(settings, state, question, answer);
41  std::cout << state;
42  }
43 
44  return 0;
45 }
This file defines print operator headers for custom structs and a template for printing a vector....
Answer ask_answer()
Ask the user to provide an answer.
Definition: input.cpp:37
Question ask_question()
Ask the user to provide a question.
Definition: input.cpp:25
This file defines user input function headers.
int main(int argc, char **argv)
Definition: main.cpp:13
Settings options(const int argc, const char **argv)
Parse the command line arguments and generate the settings from these.
Definition: opts.cpp:85
This file defines the command line argument parsing function header.
bool Answer
An answer returned by a player. The answer is either true or false denoting he/she has or does not ha...
Definition: round.h:39
This file defines the settings struct.
State init_state(const Settings &settings)
Initialize the starting state corresponding to the given settings.
Definition: state.cpp:58
This file defines the structs for a card, player and a game state, plus a state initialize and copy f...
A question asked by a player. The player asks another player for a specific card from a certain set.
Definition: round.h:17
The settings which characterize a game.
Definition: settings.h:22
The complete game state.
Definition: state.h:57
std::vector< int > quartets
The information of who has a certain quartet.
Definition: state.h:90
void update_state(const Settings &settings, State &state, const Question &question, const Answer &answer)
Update the state of the game according to the question asked and the answer which is given.
Definition: update.cpp:155
This file defines the state update function headers.
bool * valid_question(const Settings &settings, const State &state, const Question &question)
Check if the question asked is valid.
Definition: validate.cpp:89
This file defines function headers for functions that can check if a question or state is valid.