Quaternity
Functions
debug.cpp File Reference

This file defines print operators for custom structs. These are useful for debugging purposes. More...

#include <iostream>
#include <vector>
#include "debug.h"
#include "round.h"
#include "settings.h"
#include "state.h"

Go to the source code of this file.

Functions

std::ostream & operator<< (std::ostream &out, const Card &card)
 Print the information of a card struct. More...
 
std::ostream & operator<< (std::ostream &out, const Player &player)
 Print the information of a player struct. More...
 
std::ostream & operator<< (std::ostream &out, const Settings &settings)
 Print the information of a settings struct. More...
 
std::ostream & operator<< (std::ostream &out, const State &state)
 Print the information of a state struct. More...
 
std::ostream & operator<< (std::ostream &out, const Question &question)
 Print the information of a question struct. More...
 

Detailed Description

This file defines print operators for custom structs. These are useful for debugging purposes.

Definition in file debug.cpp.

Function Documentation

◆ operator<<() [1/5]

std::ostream& operator<< ( std::ostream &  out,
const Card card 
)

Print the information of a card struct.

Definition at line 19 of file debug.cpp.

20 {
21  out << card.players;
22  return out;
23 }
std::vector< bool > players
The players which could have this card.
Definition: state.h:28

◆ operator<<() [2/5]

std::ostream& operator<< ( std::ostream &  out,
const Player player 
)

Print the information of a player struct.

Definition at line 28 of file debug.cpp.

29 {
30  out << "(" << player.num_cards << "," << player.sets << ")";
31  return out;
32 }
std::vector< int > sets
The number of cards the player at least has from a certain set.
Definition: state.h:48
int num_cards
The number of cards this player has.
Definition: state.h:39

◆ operator<<() [3/5]

std::ostream& operator<< ( std::ostream &  out,
const Question question 
)

Print the information of a question struct.

Definition at line 61 of file debug.cpp.

62 {
63  out << "Question: "
64  << "player = " << question.player << ", "
65  << "set = " << question.set << ", "
66  << "card = " << question.card << "." << std::endl;
67  return out;
68 }
int set
The set the card which is asked belongs to.
Definition: round.h:27
int player
The player the question is asked to.
Definition: round.h:22
int card
The card in the set which is asked for.
Definition: round.h:32

◆ operator<<() [4/5]

std::ostream& operator<< ( std::ostream &  out,
const Settings settings 
)

Print the information of a settings struct.

Definition at line 37 of file debug.cpp.

38 {
39  out << "Settings: "
40  << "set size = " << settings.SET_SIZE << ", "
41  << "num sets = " << settings.NUM_SETS << ", "
42  << "num players = " << settings.NUM_PLAYERS << "." << std::endl;
43  return out;
44 }
const int NUM_SETS
The number of sets.
Definition: settings.h:32
const int SET_SIZE
The size of one set, aka the number of cards in one set.
Definition: settings.h:27
const int NUM_PLAYERS
The number of players playing the game.
Definition: settings.h:37

◆ operator<<() [5/5]

std::ostream& operator<< ( std::ostream &  out,
const State state 
)

Print the information of a state struct.

Definition at line 49 of file debug.cpp.

50 {
51  out << "Onturn: " << state.onturn << std::endl
52  << "Cards: " << state.cards << std::endl
53  << "Players: " << state.players << std::endl
54  << "Quartets: " << state.quartets << std::endl;
55  return out;
56 }
std::vector< Player > players
The information on all the players.
Definition: state.h:81
std::vector< Card > cards
The information on all the cards.
Definition: state.h:74
int onturn
The player who is on turn.
Definition: state.h:62
std::vector< int > quartets
The information of who has a certain quartet.
Definition: state.h:90