-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
274 lines (227 loc) · 9.69 KB
/
Copy pathmain.cpp
File metadata and controls
274 lines (227 loc) · 9.69 KB
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
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include "niveau.h"
using namespace std;
//-------------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------- LES VARIABLES ------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------------------------------------
string lstAttaques[][5] =
{
{"0","Attaque","10"},
{"1","Tonnerre","30"},
{"2","Boule de feu","20"},
{"3","Trou Noir","25"},
{"4","Lumicanon","30"},
};
int lstDegat[5] ={10,30,20,25,30};
int messageId;
//-------------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------- LES CLASSES --------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------------------------------------
class Personnage
{
public:
Personnage(string n, bool h, int v)
: nom(n), hero(h), vie(v)
{}
string getNom() const { return nom; }
bool getHero() const { return hero; }
int getVie() const { return vie; }
void setNom(string n) { nom = n;};
void setHero(bool h) { hero = h;};
void setVie(int v) { vie = v;};
private:
string nom;
bool hero;
int vie;
};
//-------------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------- LES FONCTIONS ------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------------------------------------
int MessageDebut(Personnage mechant , Personnage hero)
{
int i;
string message[] =
{
"Vous entrez dans une taverne et " + mechant.getNom() + " vous acceuil avec un air menaçant",
"Vous voulez couper du bois mais " + mechant.getNom() + " plante sa hache dedans avant vous et veux vous le voler",
"Vous marchez dans la rue mais " + mechant.getNom() + " est sur votre trottoire et vous l'aggressez sans raison valable",
"Olala, le scenario vous force a affronter " + mechant.getNom() +" quel choc :O",
mechant.getNom() + ": OHOH, tu oses t'approcher de moi? \n" + hero.getNom() + ": je ne peut pas te battre sans m'approcher de toi",
"Vous decouvrez que " + mechant.getNom() + " joue des personnages de distance sur la top lane",
mechant.getNom() + " joue a des jeux videos et est en retard pour son projet, il met en retard son camarade",
mechant.getNom() + " dit pain au chocolat au lieu de chocolatine, il faut le tuer",
mechant.getNom() + " pense qu'ecrire un scenario est facile, vous voulez le frapper",
mechant.getNom() + " ne met pas d'ecouteurs dans les transports publiques, il merite une lecon",
mechant.getNom() + " n'aime pas minecraft, vous sortez votre hache en diamant",
mechant.getNom() + " pense qu'on manque d'idee pour les intros, vous n'etes pas d'accord",
mechant.getNom() + " trouv de fote dortografe & vou arcel"
};
srand(time(0));
i = rand() % (sizeof(message)/sizeof(*message));
cout << message[i] << "\n\n\n";
return i;
}
void Victoire(Personnage mechant, Personnage hero, int i)
{
string message[] =
{
mechant.getNom() + " est KO, vous pouvez boire votre bierre",
mechant.getNom() + " est vaincu, vous avez voir bois",
mechant.getNom() + " n'est plus sur votre trottoire, vous etes un monstre",
"Olala, vous avez vaincu " + mechant.getNom(),
hero.getNom() + ": La prochaine chose que tu vas dire est : C'EST IMPOSSIBLE \n" + mechant.getNom() + ": C'EST IMPOSSIBLE !!!",
"Felicitation, vous venez d'eradiquer le sida",
mechant.getNom() + " s'appelait en vrai Maxime",
"La team chocolatine viens de gagner",
"Il n'avait pas tord, vous vous sentez tres mal de l'avoir assassinee",
mechant.getNom() + " a ete retrouve mort rouee de coup",
"En fuyant le combat " + mechant.getNom() + " c'est pris un creeper en plein visage ",
mechant.getNom() + " a totalement raison",
"lortograf cere a ri1"
};
cout << "VICTOIRE \n" << message[i] << endl;
}
void Defaite(Personnage mechant, Personnage hero, int i)
{
string message[] =
{
mechant.getNom() + " bois une bierre sur votre corps",
mechant.getNom() + " a volee tout le bois",
"Vous perdez votre combat et la police vous arrete pour agression",
"Olala, vous avez perdu",
mechant.getNom() + ": ROADA ROLLA DAH",
mechant.getNom() + " a gagne sa top lane, quelle surprise",
mechant.getNom() + " n'est finalement pas en retard et tout est calcule",
"La team pain au chocolat a gagne, la france est en deuil",
mechant.getNom() + " avais tord et on ne sais meme pas comment faire un scenario de defaite dans ces conditions",
"Avec la puissance de Yung Gravy, le train c'est transformee en Gravy Train",
mechant.getNom() + " sors son sniper de Phantom Force sur Roblox et vous 360 noscope across the map",
mechant.getNom() + " pense qu'on manque d'idee pour les defaites et a raison",
"L'ortographe regne sur la terre "
};
cout << "DEFAITE \n" << message[i] << endl;
}
Personnage creaHero()
{
string nom;
cout << "Quel est votre nom aventurier?" << endl;
cout << "Votre nom : ";
getline(cin,nom);
cout << endl;
Personnage hero(nom, 1, 100);
return hero;
}
string generationNomMechant()
{
srand(time(0));
string listeNom[] = {"leBlanc","leGris","leNoir","le Maudit","le maitre des haches","le maitre des lames","le grand","le petit"};
string listePrenom[] = {"Draven","Balthazar","Jinx","Igor","Mathieu","Jack","Oscar","Nicolas","Bob"};
string nom =listePrenom[rand() % (sizeof(listePrenom)/sizeof(*listePrenom))];
nom += " " + listeNom[rand() % (sizeof(listeNom)/sizeof(*listeNom))];
return nom;
}
Personnage creaMechant()
{
string nom = generationNomMechant();
Personnage mechant(nom, 0, 100);
return mechant;
}
void afficheStat(Personnage hero, Personnage mechant)
{
cout << "Nom hero : " << hero.getNom() << endl;
cout << "Vie hero : " << hero.getVie() << endl << endl << endl;
cout << "Nom mechant : " << mechant.getNom() << endl;
cout << "Vie mechant : " << mechant.getVie() << endl << endl;
}
Personnage attaque(Personnage attaquant, Personnage victime)
{
int choice;
int pvVictime = victime.getVie();
int i,j;
if(attaquant.getHero())
{
cout << attaquant.getNom() << " Choissisez votre attaque (numero) : " << endl;
/* Affichage de la liste des attaques */
for ( i = 0; i < 5; i++ ) {
for ( j = 0; j < 5; j++ ) {
if( j == 0 || j == 1 ){
cout << " " << lstAttaques[i][j] ;
}
}
cout << endl;
}
cin >> choice ;
cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
if (choice <= 4)
{
pvVictime -= lstDegat[choice];
victime.setVie(pvVictime);
cout << "Le hero a utilise l'attaque " << lstAttaques[choice][1] << " et a fais " << lstDegat[choice] << " degats" << endl << endl;
} else {
cout << "Vous ratez votre attaque" << endl;
cout << endl;
}
}
else
{
srand(time(0));
choice = rand() % 4;
pvVictime -= lstDegat[choice];
victime.setVie(pvVictime);
cout << "Le mechant a utilise l'attaque " << lstAttaques[choice][1] << " et a fais " << lstDegat[choice] << " degats" << endl << endl;
}
return victime;
}
void Combat(Personnage hero, Personnage mechant)
{
if ( hero.getVie() >= mechant.getVie() ){
mechant = attaque(hero, mechant);
hero = attaque(mechant, hero);
} else {
hero = attaque(mechant, hero);
mechant = attaque(hero, mechant);
}
if( hero.getVie() <= 0){
Defaite(mechant, hero, messageId);
} else if (mechant.getVie() <= 0) {
Victoire(mechant, hero, messageId);
} else {
afficheStat(hero, mechant);
Combat(hero, mechant);
}
}
bool restartPrompt()
{
string choice;
cout << "voulez vous rejouer ? [y/n]" << endl;
cin >> choice;
if (choice == "y")
{
cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
return true;
}
else
{
cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
return false;
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------- MAIN ---------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------------------------------------
int main()
{
bool restart = true;
Personnage hero = creaHero();
Personnage mechant = creaMechant();
while(restart)
{
hero.setVie(100);
mechant = creaMechant();
messageId = MessageDebut(mechant, hero);
Combat(hero, mechant);
restart = restartPrompt();
}
}