-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPersonnage.cpp
296 lines (242 loc) · 5.65 KB
/
Personnage.cpp
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
#include "Personnage.h"
using namespace std;
Personnage::Personnage()
{
m_vieMax = 100;
m_vie = 100;
m_mana = 0;
Arme Arme;
Potion Potion;
changerArme(0, Arme);
m_efficacePopo = 1;
m_degats = 3;
m_defense = 3;
m_OR = m_experience = m_niveau = 0;
nombrePotion[0] = 5;
nombrePotion[1] = 3;
nombrePotion[2] = 2;
nombrePotion[3] = 1;
}
Personnage::~Personnage()
{
}
void Personnage::recevoirDegats(int nbDegats, int bonus, string nomAttaque)
{
int nombreDegat = 0;
if (nomAttaque == "Defense")
{
nombreDegat = ((nbDegats + bonus) - 2 * (m_defense + m_defenseArmure + m_defenseArmure * m_niveau));
if (nombreDegat > 0)
m_vie -= ((nbDegats + bonus) - (m_defense + m_defenseArmure + m_defenseArmure * m_niveau));
}
else
{
nombreDegat = ((nbDegats + bonus) - (m_defense + m_defenseArmure + m_defenseArmure * m_niveau));
if (nombreDegat > 0)
m_vie -= ((nbDegats + bonus) - (m_defense + m_defenseArmure + m_defenseArmure * m_niveau));
}
if (m_vie <= 0)
m_vie = 0;
}
void Personnage::attaquer(Adversaire &cibleb, string nomAttaque)
{
cibleb.recevoirDegats(m_degatArme, m_degats + (m_degats * m_niveau), nomAttaque);
}
void Personnage::boirePotionDeVie(string nomPotion, Potion &ciblePotion)
{
ciblePotion.boire(nomPotion, &m_vie, &m_efficacePopo, m_niveau, nombrePotion );
if (m_vie > m_vieMax)
{
m_vie = m_vieMax;
}
}
void Personnage::changerArme(int numero, Arme &ciblea)
{
ciblea.changer(numero, &m_nomArme, &m_degatArme);
}
bool Personnage::estVivant()
{
return (m_vie > 0);
}
void Personnage::afficherEtat()
{
cout << "Vie : " << m_vie << endl;
cout << "Expérience : " << m_experience << "\n";
cout << "Argent : " << m_OR << "\n";
cout << "Arme : " << m_nomArme << " (Degats : " << m_degatArme << ")" << endl<<"\n";
cout << "Petite potion : " << nombrePotion[0] << "\n";
cout << "Moyenne potion : " << nombrePotion[1] << "\n";
cout << "Grande potion : " << nombrePotion[2] << "\n";
cout << "Potion Miraculeuse : " << nombrePotion[3] << "\n";
}
bool Personnage::fullLife()
{
return (m_vie == m_vieMax);
}
void Personnage::sortirArme(int numero, Gain &ciblegain, Arme &ciblearme)
{
ciblegain.GainArme(&m_nomArme, &m_degatArme, numero, ciblearme);
}
void Personnage::sortirPotion(int nouvellePotion, int nombreNouvellePotion)
{
nombrePotion[nouvellePotion] += nombreNouvellePotion;
}
void Personnage::sortirArgent(int gainOr, Gain &cible3gain)
{
cible3gain.GainOR(&m_OR, gainOr);
}
void Personnage::sortirExperience(int gainExperience, Gain &cible4gain)
{
cible4gain.Experience(&m_vie, &m_vieMax, &m_niveau, &m_experience, gainExperience);
}
// En dessous, sortir pour affichage
int Personnage::sortirNiveau()
{
return m_niveau;
}
float Personnage::sortirPV()
{
return m_vie;
}
float Personnage::sortirPVmax()
{
return m_vieMax;
}
string Personnage::sortirnomArme()
{
return m_nomArme;
}
int Personnage::sortirdegatArme()
{
return m_degatArme;
}
int Personnage::sortirxp()
{
return m_experience;
}
int* Personnage::sortirNombrePotion()
{
return nombrePotion;
}
void Personnage::restart()
{
m_vieMax = 100;
m_vie = 100;
m_mana = 0;
Arme Arme;
Potion Potion;
changerArme(0, Arme);
m_efficacePopo = 1;
m_degats = 3;
m_defense = 3;
m_OR = m_experience = m_niveau = 0;
nombrePotion[0] = 5;
nombrePotion[1] = 3;
nombrePotion[2] = 2;
nombrePotion[3] = 1;
}
Adversaire::Adversaire(int niveau) // Loup
{
m_AvieMax = 30+(5*niveau);
m_Avie = 30+(5*niveau);
m_Amana = 0;
m_AnomArme = "Aucune arme";
m_AdegatArme = 0;
m_AnomArmure = "Aucune armure";
m_AdefenseArmure = 0;
m_AefficacePopo = 0.0;
m_Adegats = 12+(0.5*niveau);
m_Adefense = 3+(0.5*niveau);
}
Adversaire::Adversaire(int nom, int niveau) // Squelette
{
m_AvieMax = 50+(10*niveau);
m_Avie = 50+(10*niveau);
m_Amana = 0;
m_AnomArme = "Epee";
m_AdegatArme = 15;
m_AnomArmure = "Fer";
m_AdefenseArmure = 6;
m_AefficacePopo = 0.7;
m_Adegats = 1+(1*niveau);
m_Adefense = 1+(0.5*niveau);
nombrePotion[0] = 2;
nombrePotion[1] = 1;
nombrePotion[2] = 0;
nombrePotion[3] = 0;
}
Adversaire::Adversaire(string nom, int niveau) // Dragon
{
m_AvieMax = 300+(15 * niveau);
m_Avie = 300 + (15 * niveau);
m_Amana = 0;
m_AnomArme = "Aucune Arme";
m_AdegatArme = 0;
m_AnomArmure = "Aucune Armure";
m_AdefenseArmure = 0;
m_AefficacePopo = 0.0;
m_Adegats = 35 + (5 * niveau);
m_Adefense = 50 + (9 * niveau);
}
Adversaire::~Adversaire()
{
}
void Adversaire::recevoirDegats(int nbDegats, int bonus, string nomAttaque)
{
int degat = 0;
if (nomAttaque == "Tranche")
{
degat = ((nbDegats + bonus) - (m_Adefense + m_AdefenseArmure));
if (degat > 0)
m_Avie -= degat;
}
else if (nomAttaque == "Coup de tete")
{
degat = 0.3*((nbDegats + bonus) - (m_Adefense + m_AdefenseArmure));
if (degat > 0)
m_Avie -= degat;
}
else
{
degat = 0.6*((nbDegats + bonus));
if (degat > 0)
m_Avie -= degat;
}
if (m_Avie <= 0)
m_Avie = 0;
}
void Adversaire::attaquer(Personnage &cible4, string nomAttaque)
{
cible4.recevoirDegats(m_AdegatArme, m_Adegats, nomAttaque);
}
void Adversaire::boirePotionDeVie(string nomPotion, Potion &cible2Potion)
{
cible2Potion.boire(nomPotion, &m_Avie, &m_AefficacePopo, 0, nombrePotion);
if (m_Avie > m_AvieMax)
{
m_Avie = m_AvieMax;
}
}
bool Adversaire::estVivant()
{
return (m_Avie > 0);
}
void Adversaire::afficherEtat()
{
cout << "Vie : " << m_Avie << endl;
//cout << "Mana : " << m_mana << endl;
cout << "Arme : " << m_AnomArme << " (Degats : " << m_AdegatArme << ")" << endl;
cout << "Armure : " << m_AnomArmure << " (Defense : " << m_AdefenseArmure << ")" << "\n" << "\n";
}
bool Adversaire::fullLife()
{
return (m_Avie == m_AvieMax);
}
float Adversaire::sortirPV()
{
return m_Avie;
}
float Adversaire::sortirPVmax()
{
return m_AvieMax;
}