-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonster.cpp
More file actions
41 lines (31 loc) · 897 Bytes
/
Monster.cpp
File metadata and controls
41 lines (31 loc) · 897 Bytes
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
#include "./Monster.hpp"
#include "./Menu.hpp"
void Monster::teamAttack() {
int damage = 0;
int nbrOfCharacters = charactersList.size();
Menu::toScreen(
"",
this->name + " attaque le groupe...",
""
);
for(Character* character : charactersList) {
if (character->getJob() != 7) {
damage = (this->physicalAttack / nbrOfCharacters) - character->getDefense();
character->receiveDamage(damage);
}
}
}
void Monster::randomAction() {
int randomNbr = rand()%3;
int target = rand()%3;
if(randomNbr == 0) {
this->attack(*Character::charactersList[target]);
} else if (randomNbr == 1) {
this->teamAttack();
} else {
this->increaseDefense(*Character::charactersList[target+3],20);
}
}
void Monster::launchSpecialAction(Character& c) {
randomAction();
}