-
Notifications
You must be signed in to change notification settings - Fork 0
/
SkillComponent.cpp
45 lines (38 loc) · 1.1 KB
/
SkillComponent.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
#include "stdafx.h"
#include "SkillComponent.h"
//Constructors and Destructor:
SkillComponent::SkillComponent()
{
this->skills.push_back(Skill(SKILLS::HEALTH));
this->skills.push_back(Skill(SKILLS::ATTACK));
this->skills.push_back(Skill(SKILLS::ACCURACY));
this->skills.push_back(Skill(SKILLS::ENDURANCE));
}
SkillComponent::~SkillComponent()
{
}
const int SkillComponent::getSkillLevel(const int skill) const
{
if (skills.empty() || skill < 0 || static_cast<size_t>(skill) >= this->skills.size())
{
// std::cout << "ERROR::SkillComponent::Skill does not exist: " << key << std::endl;
throw "ERROR::SkillComponent::getSkillLevel::Skill does not exist: " + skill;
}
else
{
return this->skills[skill].getLevel();
}
return -1;
}
const void SkillComponent::gainExp(const int skill, const int exp)
{
if (skills.empty() || skill < 0 || static_cast<size_t>(skill) >= this->skills.size())
{
// std::cout << "ERROR::SkillComponent::Skill does not exist: " << key << std::endl;
throw "ERROR::SkillComponent::gainExp::Skill does not exist: " + skill;
}
else
{
this->skills[skill].gainExp(exp);
}
}