-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimaux.cpp
More file actions
115 lines (108 loc) · 2.55 KB
/
animaux.cpp
File metadata and controls
115 lines (108 loc) · 2.55 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
#include "animaux.hpp"
#include "univers.hpp"
void Animal::naissance(int nAge, char nSexe, int nFaim, int iPosX, int iPosY, char nNourriture, int nMaxAge, int nMaxFaim, int nMaxRepr, char nEspece){
espece = nEspece;
age = nAge;
sexe = nSexe;
faim = nFaim;
posX = iPosX;
posY = iPosY;
nourriture = nNourriture;
maxAge = nMaxAge;
maxFaim = nMaxFaim;
reproduction = false;
maxAttenteReproduction = nMaxRepr;
attenteReproduction = 0;
maxAttenteNaissance = 2;
attenteNaissance = maxAttenteNaissance;
maxAttenteNourrir = 2;
attenteNourrir = maxAttenteNourrir;
prevX = iPosX;
prevY = iPosY;
}
void Animal::seDeplacer(int nPosX, int nPosY){
prevX = this->posX;
prevY = this->posY;
this->posX = nPosX;
this->posY = nPosY;
}
void Animal::plusAge(){
age++;
}
void Animal::plusFaim(){
faim++;
}
void Animal::moinsAttenteReproduction(){
if(attenteReproduction > 0) --attenteReproduction;
}
void Animal::moinsAttenteNaissance(){
if(attenteNaissance > 0) --attenteNaissance;
}
void Animal::moinsAttenteNourrir(){
if(attenteNourrir > 0) --attenteNourrir;
}
void Animal::seReproduire(int px, int py){
partX = px;
partY = py;
attenteNaissance = maxAttenteNaissance;
reproduction = true;
}
void Animal::finReproduction(){
partX = -1;
partY = -1;
reproduction = false;
attenteReproduction = maxAttenteReproduction;
attenteNaissance = maxAttenteNaissance;
}
void Animal::seNourrir(){
faim = 0;
attenteNourrir = maxAttenteNourrir;
}
int Animal::estMort(){
if(faim > maxFaim) return 1;
if(age > maxAge) return 2;
return 0;
}
int Animal::getPosX(){
return posX;
}
int Animal::getPosY(){
return posY;
}
char Animal::getEspece(){
return this->espece;
}
bool Animal::getReproduction(){
return reproduction;
}
char Animal::getSexe(){
return sexe;
}
int Animal::getPartX(){
return partX;
}
int Animal::getPartY(){
return partY;
}
int Animal::getFaim(){
return faim;
}
int Animal::getAttenteReproduction(){
return attenteReproduction;
}
int Animal::getAttenteNaissance(){
return attenteNaissance;
}
int Animal::getAttenteNourrir(){
return attenteNourrir;
}
bool Animal::backTrack(int newX, int newY){
if(newX == prevX && newY == prevY) return true;
return false;
}
Mouton::Mouton(int nPosX, int nPosY, char nSexe){
Animal::naissance(0, nSexe, 0, nPosX, nPosY, HERBE, 50, 5, 4, MOUTON);
}
Loup::Loup(int nPosX, int nPosY, char nSexe){
Animal::naissance(0, nSexe, 0, nPosX, nPosY, MOUTON, 60, 10, 6, LOUP);
}