-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.h
85 lines (59 loc) · 1.95 KB
/
game.h
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
#ifndef GAME_H
#define GAME_H
#include <QObject>
#include <QString>
#include <vector>
#include "player.h"
// The Game class manages the logic and state of the game
class Game : public QObject {
Q_OBJECT
public:
// Constructor that initializes the game with two players
Game(Player *player1, Player *player2, QObject *parent = nullptr);
// Starts a new round in the game
void startNewRound();
// Returns the current drawer player
Player* getCurrentDrawer() const;
// Returns the current guesser player
Player* getCurrentGuesser() const;
// Returns the word to be guessed
QString getWordToGuess() const;
// Sets the word to be guessed
void setWordToGuess(QString word);
// Processes a guess made by the guesser
bool makeGuess(const QString &guess);
// Generates a random word from the word list
QString generateRandomWord();
// Returns the number of attempts made in the current round
int getAttempts();
// Returns the length of the word to be guessed
QString getWordLength();
// Switches the roles of the drawer and guesser
void switchRoles();
// Increases the round number
void increaseRound();
// Returns the current round number
int getRound();
private:
// Pointers to the two players in the game
Player *player1;
Player *player2;
// Pointers to the current drawer and guesser
Player *currentDrawer;
Player *currentGuesser;
// The word that needs to be guessed
QString wordToGuess;
// The number of attempts made in the current round
int attempts;
// The maximum number of attempts allowed
const int maxAttempts = 5;
// A list of possible words to be guessed
std::vector<QString> wordList;
// The current round number
int round;
// Returns the score of the current guesser
int getGuesserScore();
// Returns the score of the current drawer
int getDrawerScore();
};
#endif // GAME_H