-
Notifications
You must be signed in to change notification settings - Fork 0
/
Controller.hpp
147 lines (119 loc) · 2.95 KB
/
Controller.hpp
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#ifndef LABO4_RIVER_CONTROLLER_HPP
#define LABO4_RIVER_CONTROLLER_HPP
#include <string>
#include "Container/Bank.hpp"
#include "Container/Boat.hpp"
#include "ErrorManager.hpp"
/**
* @brief Controller to manage the River game.
* @authors Luca Coduri & Chloé Fontaine
*/
class Controller : public ErrorManager{
public:
/**
* @brief Contructor that initializes the River game.
*/
Controller();
~Controller() override;
Controller(const Controller&) = delete;
Controller& operator=(const Controller&) = delete;
/**
* @brief Start the game.
*/
void start();
/**
* @brief Show the help menu.
*/
static void showMenu();
/**
* @brief Display the game board.
*/
void display() const;
void manageError(const std::string& message) override;
private:
/**
* @brief Display the game board and execute new command.
*/
void nextTurn();
/**
* @brief Reset game state.
*/
void reset();
/**
* @brief Initialize game's persons.
*/
void initPersons();
/**
* @brief Initialize game state variables.
*/
void initStateVar();
/**
* @brief Print a help menu row with the right format
*
* @param param command
* @param description description of the command
*/
static void printMenuRow(const std::string& param, const std::string&
description);
/**
* @brief Print the boat if it is next to the given bank.
*
* @param bank bank to check
*/
void printBoat(Bank* bank) const;
/**
* @brief Print boundaries of the game board with the given separator.
*
* @param sep Character to print as a separator.
*/
void printBoundary(char sep) const;
/**
* @brief Ask the user for a command and execute it.
*/
void executeCommand();
/**
* @brief Embark a person on the boat.
*
* @param person Person to embark.
* @return true if the person could be embarked, false otherwise.
*/
bool embark(Person* person);
/**
* @brief Disembark a person from the boat in its bank.
*
* @param person Person to disembark.
* @return true if the person could be disembarked, false otherwise.
*/
bool land(Person* person);
/**
* @brief Move the boat to the next bank.
*/
void moveBoat();
/**
* @brief Get the person with the given name.
*
* @param name Name of the person.
* @return The person with the given name if found, nullptr otherwise.
*/
Person* getPerson(const std::string& name) const;
/**
* @brief Check if the game is finished.
*/
void checkGameState();
/**
* @brief Delete all persons.
*/
void deletePersons();
int turn;
bool gameFinished;
bool gameWon;
Bank* leftBank;
Bank* rightBank;
Boat* boat;
std::list<Person*> persons;
const long long GAME_SIZE = 70;
const size_t BOAT_SIZE = 2;
char BANK_SEP = '-';
char RIVER_SEP = '=';
};
#endif //LABO4_RIVER_CONTROLLER_HPP