-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathratiogain.cpp
More file actions
122 lines (105 loc) · 2.53 KB
/
ratiogain.cpp
File metadata and controls
122 lines (105 loc) · 2.53 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
#include "ratiogain.h"
using namespace std;
Ratio::Ratio()
{
for (int i = 0; i < 21; i++)
armeDejaPossede[i] = false;
armeDejaPossede[0] = true;
}
int Ratio::rand_a_b(int a, int b)
{
return rand() % (b - a) + a;
}
int Ratio::GainArme(Personnage &ciblepersonnage, Gain &ciblegain, Arme &ciblearme)
{
bool dejaTout = true;
dejaEnPossession = false;
int nombreAleatoire = 0;
do {
dejaEnPossession = false;
nombreAleatoire = rand_a_b(1, 20);
if (nombreAleatoire == 6 || nombreAleatoire == 10 || nombreAleatoire == 12 || nombreAleatoire == 18)
nombreAleatoire = rand_a_b(1, 20);
if (armeDejaPossede[nombreAleatoire])
dejaEnPossession = true;
if (!dejaEnPossession)
{
armeDejaPossede[nombreAleatoire] = true;
}
for (int i = 0; i < 20; i++)
{
if (armeDejaPossede[i] == false)
dejaTout = false;
}
if (dejaTout)
dejaEnPossession = false;
} while (dejaEnPossession);
if (dejaTout)
return 0;
else
return nombreAleatoire;
}
bool* Ratio::sortirArmeEnPossession()
{
return armeDejaPossede;
}
void Ratio::GainPotion(Personnage &ciblepersonnage)
{
int nombreAleatoire = rand_a_b(0, 6);
int nombrePotion = rand_a_b(0, 6);
int nouvellePotion=0;
if (nombreAleatoire = 5)
{
nouvellePotion = 2;
nombrePotion = 1;
}
else if (nombreAleatoire > 2 && nombreAleatoire < 5)
{
nouvellePotion = 1;
if (nombrePotion < 4)
nombrePotion = 1;
else
nombrePotion = 2;
}
else if (nombreAleatoire < 3)
{
nouvellePotion = 0;
if (nombrePotion < 3)
nombrePotion = 1;
else if (nombrePotion < 5)
nombrePotion = 2;
else
nombrePotion = 3;
}
ciblepersonnage.sortirPotion(nouvellePotion, nombrePotion);
}
void Ratio::GainOr(Personnage &ciblepersonnage, Gain &ciblegain)
{
int nombreAleatoire = rand_a_b(0, 6);
int Or;
if (nombreAleatoire = 1)
Or = 100;
else if (nombreAleatoire > 1 && nombreAleatoire < 4)
Or = 50;
else if (nombreAleatoire >3 && nombreAleatoire < 7)
Or = 30;
ciblepersonnage.sortirArgent(Or, ciblegain);
}
void Ratio::GainExperience(Personnage &ciblepersonnage, Gain &ciblegain, int numeroCombat)
{
int nombreAleatoire = rand_a_b(0, 6);
int xp=0;
if (numeroCombat == 1)
xp = 50 + (10 * nombreAleatoire);
else if (numeroCombat == 2)
xp = 100 + (10 * nombreAleatoire);
else if (numeroCombat == 3)
xp = 300 + (20 * nombreAleatoire);
ciblepersonnage.sortirExperience(xp, ciblegain);
}
int Ratio::GainArmeLegende(Personnage &ciblepersonnage, Gain &ciblegain, Arme &ciblearme)
{
int nombreAleatoire = 20;
armeDejaPossede[nombreAleatoire] = true;
return nombreAleatoire;
}