-
Notifications
You must be signed in to change notification settings - Fork 0
/
Settings.hh
248 lines (208 loc) · 4.99 KB
/
Settings.hh
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
#ifndef Settings_hh
#define Settings_hh
#include "Structs.hh"
/** \file
* Contains a class to store all the game settings that do not change
* during a game, except the names of the players.
*/
/**
* Stores most of the game settings.
*/
class Settings {
friend class Info;
friend class Board;
friend class Game;
friend class SecGame;
friend class Player;
static const int dwarves_health_ = 100;
static const int wizards_health_ = 50;
static const int orcs_health_ = 75;
static const int trolls_health_ = 500;
static const int min_damage_dwarves_ = 20;
static const int max_damage_dwarves_ = 40;
static const int min_damage_orcs_ = 15;
static const int max_damage_orcs_ = 30;
static const int min_damage_trolls_ = 50;
static const int max_damage_trolls_ = 150;
static const int ini_treasures_ = 80;
static const int inv_prob_abyss_ = 25;
static const int inv_prob_orc_ = 50;
int nb_players_;
int nb_rounds_;
int nb_dwarves_;
int nb_wizards_;
int max_nb_orcs_;
int nb_trolls_;
int treasure_value_;
int rock_resistance_;
int rows_;
int cols_;
/**
* Reads the settings from a stream.
*/
static Settings read_settings (istream& is);
public:
/**
* Returns a string with the game name and version.
*/
inline static string version () {
return "Moria 1.1";
}
/**
* Returns the number of players in the game.
*/
inline int nb_players () const {
return nb_players_;
}
/**
* Returns the total number of rounds of a game.
*/
inline int nb_rounds () const {
return nb_rounds_;
}
/**
* Returns the initial number of dwarves for every player.
*/
inline int nb_dwarves () const {
return nb_dwarves_;
}
/**
* Returns the initial number of wizards for every player.
*/
inline int nb_wizards () const {
return nb_wizards_;
}
/**
* Returns the maximum number of orcs.
*/
inline int max_nb_orcs () const {
return max_nb_orcs_;
}
/**
* Returns the constant number of trolls.
*/
inline int nb_trolls () const {
return nb_trolls_;
}
/**
* Returns the value of a treasure w.r.t. the value of a conquered cell.
*/
inline int treasure_value () const {
return treasure_value_;
}
/**
* Returns the number of 'attacks' needed to excavate a rock.
*/
inline int rock_resistance () const {
return rock_resistance_;
}
/**
* Returns the number of rows of the grid of the game.
*/
inline int rows () const {
return rows_;
}
/**
* Returns the number of columns of the grid of the game.
*/
inline int cols () const {
return cols_;
}
/**
* Returns the initial (and maximum) health of the dwarves.
*/
inline int dwarves_health () const {
return dwarves_health_;
}
/**
* Returns the initial (and maximum) health of the wizards.
*/
inline int wizards_health () const {
return wizards_health_;
}
/**
* Returns the initial (and maximum) health of the orcs.
*/
inline int orcs_health () const {
return orcs_health_;
}
/**
* Returns the initial (and maximum) health of the trolls.
*/
inline int trolls_health () const {
return trolls_health_;
}
/**
* Returns the minimum damage inflicted by a dwarf attack.
*/
inline int min_damage_dwarves () const {
return min_damage_dwarves_;
}
/**
* Returns the maximum damage inflicted by a dwarf attack.
*/
inline int max_damage_dwarves () const {
return max_damage_dwarves_;
}
/**
* Returns the minimum damage inflicted by an orc attack.
*/
inline int min_damage_orcs () const {
return min_damage_orcs_;
}
/**
* Returns the maximum damage inflicted by an orc attack.
*/
inline int max_damage_orcs () const {
return max_damage_orcs_;
}
/**
* Returns the minimum damage inflicted by a troll attack.
*/
inline int min_damage_trolls () const {
return min_damage_trolls_;
}
/**
* Returns the maximum damage inflicted by a troll attack.
*/
inline int max_damage_trolls () const {
return max_damage_trolls_;
}
/**
* Returns the initial number of treasures on the board.
*/
inline int ini_treasures () const {
return ini_treasures_;
}
/**
* Returns 1/(the probability of a rock becoming an abyss).
*/
inline int inv_prob_abyss () const {
return inv_prob_abyss_;
}
/**
* Returns 1/(the probability of an abyss producing an orc at each round).
*/
inline int inv_prob_orc () const {
return inv_prob_orc_;
}
/**
* Returns whether pl is a valid player identifier.
*/
inline bool player_ok (int pl) const {
return pl >= 0 and pl < nb_players();
}
/**
* Returns whether (i, j) is a position inside the board.
*/
inline bool pos_ok (int i, int j) const {
return i >= 0 and i < rows() and j >= 0 and j < cols();
}
/**
* Returns whether p is a position inside the board.
*/
inline bool pos_ok (Pos p) const {
return pos_ok(p.i, p.j);
}
};
#endif