forked from JohnAnthony/TROG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stattome.cpp
117 lines (106 loc) · 2.93 KB
/
stattome.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
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
#include "stattome.hpp"
#include "character.hpp"
#include "gui.hpp"
#include <sstream>
static char const * const CategoryTexts[StatTome::LAST_CATEGORY] = {
"bodily vigour",
"enervation",
"bodily strength",
"rhino's hide",
"the swordsman",
"the acrobat",
"sorcerer's might",
"dwarven courage",
"higher learning"
};
StatTome::StatTome(unsigned int pot) {
this->potency = rand() % pot + 5;
this->type = Item::STAT_TOME;
this->category = (StatTome::Category)(rand() % StatTome::LAST_CATEGORY);
this->symbol = 'B';
this->colour = COL_RED;
}
std::string
StatTome::GetName(void) {
std::stringstream ss;
ss << "A ";
if (this->potency < 10)
ss << "book";
else if (this->potency < 15)
ss << "grand book";
else if (this->potency < 20)
ss << "tome";
else if (this->potency < 25)
ss << "grand tome";
else if (this->potency < 30)
ss << "grimoire";
else
ss << "grand grimoire";
ss << " of " << CategoryTexts[this->category];
return ss.str();
}
void
StatTome::ApplyEffects(Character *c) {
std::stringstream ss;
int effect;
// Chance of a curse
if (rand() % (100 + c->curMAG + c->curWIL) < 10 + (int)this->potency) {
GUI::Alert("Something went wrong!");
c->RandomCurse(this->potency);
return;
}
effect = rand() % this->potency + 1;
ss << "Success! Your ";
switch(this->category) {
case StatTome::HEALTH:
c->baseHP += effect;
c->curHP += effect;
ss << "health";
break;
case StatTome::ENERGY:
c->baseMP += effect;
c->curMP += effect;
ss << "magical energy";
break;
case StatTome::STRENGTH:
c->baseSTR += effect;
c->curSTR += effect;
ss << "strength";
break;
case StatTome::TOUGHNESS:
c->baseTOU += effect;
c->curTOU += effect;
ss << "toughness";
break;
case StatTome::SKILL:
c->baseATT += effect;
c->curATT += effect;
ss << "attack skill";
break;
case StatTome::DODGE:
c->baseDEF += effect;
c->curDEF += effect;
ss << "defensive skill";
break;
case StatTome::MAGERY:
c->baseMAG += effect;
c->curMAG += effect;
ss << "sorcerous power";
break;
case StatTome::WILL:
c->baseWIL += effect;
c->curWIL += effect;
ss << "willpower";
break;
case StatTome::XP:
effect *= 10;
c->GiveXP(effect);
ss << "mind takes in new sighs and sounds -- your experience";
break;
case StatTome::LAST_CATEGORY:
default:
break;
}
ss << " has increased by " << effect;
GUI::Alert(ss.str());
}