forked from JohnAnthony/TROG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpotion.cpp
71 lines (63 loc) · 1.55 KB
/
potion.cpp
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
#include "potion.hpp"
#include <sstream>
static const char* PRELUDE = "Potion of ";
static const char* POTENCIES[Potion::LAST_POTENCY] = {
"Minor",
"Lesser",
"Light",
"Moderate",
"Average",
"Strong",
};
static const char* CATEGORIES[Potion::LAST_CATEGORY] = {
"Healing",
"Enervation",
"Rejuvenation",
};
Potion::Potion(Potion::Potency inPot, Potion::Category inCat) {
this->potency = inPot;
this->category = inCat;
this->type = Item::POTION;
this->symbol = 'p';
switch (this->category) {
case Potion::HEALING:
this->colour = COL_RED;
break;
case Potion::ENERVATION:
this->colour = COL_BLUE;
break;
case Potion::REJUVENATION:
this->colour = COL_PURPLE;
break;
case Potion::LAST_CATEGORY:
this->colour = COL_WHITE;
}
}
void
Potion::ApplyEffects(Character *c) {
std::stringstream ss;
int effect;
//Healing
if (this->category == HEALING || this->category == REJUVENATION) {
effect = 10;
effect += DICEROLL(potency + 1, 20);
c->Heal(effect);
}
//Mana restoration
if (this->category == ENERVATION || this->category == REJUVENATION) {
effect = 10;
effect += DICEROLL(potency + 1, 20);
c->RecoverMP(effect);
}
}
std::string
Potion::GetName(void) {
std::stringstream ss;
ss << PRELUDE;
ss << POTENCIES[this->potency];
ss << ' ';
ss << CATEGORIES[this->category];
return ss.str();
}
Potion::~Potion(void) {
}