Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
SkillSet.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <map>
4 #include <optional>
5 #include <string>
6 
10 struct SkillInfo
11 {
12  const std::string name;
13  int xp;
14 };
15 
19 class SkillSet
20 {
21 public:
22  SkillSet();
23 
28  const std::map<int, SkillInfo>& getSkills();
29 
35  std::optional<int> getSkillXp(int id);
36 
42  std::optional<int> getSkillLevel(int id);
43 
50  bool addSkillXp(int id, unsigned int amount);
51 
52 private:
53  std::map<int, SkillInfo> skillsM;
54 };
Contains all the skills that a character has.
Definition: SkillSet.hpp:20
bool addSkillXp(int id, unsigned int amount)
Adds the given amount of xp to the skill with the given id. Returns false if the addition failed,...
Definition: SkillSet.cpp:42
const std::map< int, SkillInfo > & getSkills()
Returns map with skill id keys and SkillInfo values.
Definition: SkillSet.cpp:18
std::optional< int > getSkillLevel(int id)
Returns the level of the skill calculated based on the current xp in the skill. Returns nullopt if th...
Definition: SkillSet.cpp:23
std::optional< int > getSkillXp(int id)
Returns the current xp of the skill with the given id. Returns nullopt if the skill doesn't exist.
Definition: SkillSet.cpp:32
SkillSet()
Definition: SkillSet.cpp:6
std::map< int, SkillInfo > skillsM
Key = skill id, Value = SkillInfo.
Definition: SkillSet.hpp:53
Each player has a set of skills. This struct contains the name of the skill and the current xp in the...
Definition: SkillSet.hpp:11
const std::string name
Definition: SkillSet.hpp:12
int xp
Definition: SkillSet.hpp:13