-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMage.cpp
More file actions
45 lines (39 loc) · 1.09 KB
/
Mage.cpp
File metadata and controls
45 lines (39 loc) · 1.09 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
#include "./Mage.hpp"
#include "./Menu.hpp"
bool Mage::tryUsingMp(int mp){
if(this->mp < mp){
return false;
}
this->mp -= mp;
return true;
}
void Mage::fireball(Character& other){
if(!tryUsingMp(this->maxMp*0.10f)){
return;
}
int randomNumber = rand() % 10;
if(randomNumber == 0){
Menu::toScreen(
"",
this->name + " lance une boule de feu sur " + other.name + " mais trébuche sur un tronc d'arbre et loupe la cible..." ,
""
);
return;
}
other.receiveDamage(this->magicAttack);
Menu::toScreen(
"",
this->name + " lance une boule de feu sur " + other.name + " et lui inflige " + to_string(magicAttack) + " de dégats" ,
other.name + " est à " + to_string(other.getCurrentHp()) + " pv."
);
}
string Mage::getSpecialActionName() {
if(tryUsingMp(0)) {
return "Lancez une boule de feu";
} else {
return "Lancez une boule de feu (plus assez de point magique...)";
}
}
void Mage::launchSpecialAction(Character& target) {
fireball(target);
}