-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActor.cpp
137 lines (113 loc) · 3.39 KB
/
Actor.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include <iostream>
#include <iomanip>
#include "Actor.h"
//It'll drop decimal, but not important.
int Actor::getHealthPercent(){return ((currHealth * 100)/maxHealth);}
int Actor::calcNumOfActions(int oppossingQuick)
{
//int num = ((2*quick - oppossingQuick) / 10); // faster change
//int num = (quick - opposingQuick)/10; // slower change
int num = quick / 10; //temp resolve to make the game playable and not overly difficult
if (num <= 0)
{
num = 1; //min actions possible
}
else if (num >= 10)
{
num = 10; // max actions possible
}
return num;
}
void Actor::addDebuffQueue(std::function<void(Actor& target, Actor& self)> action)
{
debuffQueue.push_back(ActionType(action));
}
void Actor::runDebuffQueue(Actor& target)
{
if (debuffQueue.size() > 0)
{
debuffQueue.front().behavior(target, *this);
debuffQueue.pop_back();
}
}
void Actor::addAction(ActionType& act)
{
actions.emplace(ALPHA_MIN + numActOptions++, act);
}
void Actor::addAction(char key, ActionType& act)
{
actions.emplace(key, act);
}
void Actor::addDefaultAction(ActionType& act)
{
actions.emplace('0', act);
}
void Actor::addActQueue(char actSymbol)
{
auto it = actions.find(actSymbol);
if (it == actions.end()) {
it = actions.find('0');
}
ActionType& act = it->second;
actQueue.push_back(act);
//actNext = '0';
};
void Actor::runActQueue(Actor& target)
{
if (actQueue.size() > 0)
{
std::cout << std::endl << name << ":" << std::endl;
for (int n = 0; n < actQueue.size(); n++)
{
ActionType act = actQueue[n];
std::cout << act.actDescript << std::endl;
act.behavior(target, *this);
std::cout << std::endl;
}
actQueue.clear();
}
}
void Actor::printStats()
{
std::string stanceText = " ";
switch (stance)
{
case Stances::BALANCED: { stanceText = "Balanced"; break; }
case Stances::OFFENSIVE: { stanceText = "Offensive"; break; }
case Stances::DEFENSIVE: { stanceText = "Defensive"; break; }
case Stances::FLIGHTY: { stanceText = "Flighty"; break; }
}
std::cout << "Current Stance: " << stanceText << std::endl << std::endl;
std::cout << "Health: " << currHealth << std::endl;
std::cout << "Physique: " << physique << std::endl;
std::cout << "Power: " << power << std::endl;
std::cout << "Quick: " << quick << std::endl;
std::cout << std::endl;
}
void Actor::printActions()
{
std::cout << "****************************Available Actions!*************************" << std::endl;
for (int i = 0; i < numActOptions; i++)
{
int maxIndent = 30;
std::cout << static_cast<char>(ALPHA_MIN + i) << " " << actions[ALPHA_MIN + i].id;
int width = (maxIndent - actions[ALPHA_MIN + i].id.length());
i++;
if (i >= numActOptions)
{
break;
}
std::cout << std::setw(width) << static_cast<char>(ALPHA_MIN + i) << " " << actions[ALPHA_MIN + i].id << std::endl;
}
std::cout << std::endl;
}
Actor::Actor(std::string name, std::string description, int health, int physique, int power, int quick)
{
this->name = name;
this->maxHealth = health;
this->currHealth = this->maxHealth;
this->physique = physique;
this->power = power;
this->quick = quick;
this->description = description;
}