Argentum Online - Servidor
attribute_manager.h
1 #ifndef ATTRIBUTE_MANAGER_H
2 #define ATTRIBUTE_MANAGER_H
3 
4 #include <unordered_map>
5 
6 #include "../../include/nlohmann/json.hpp"
7 #include "../../include/types.h"
8 
9 typedef struct stats {
10  uint32_t strength; // Fuerza
11  uint32_t agility; // Agilidad
12  uint32_t intelligence; // Inteligencia
13  uint32_t physique; // Constitucion
14 } stats_t;
15 
16 inline void to_json(nlohmann::json &j, const stats_t &s) {
17  j["strength"] = s.strength;
18  j["agility"] = s.agility;
19  j["intelligence"] = s.intelligence;
20  j["physique"] = s.physique;
21 }
22 
23 inline void from_json(const nlohmann::json &j, stats_t &s) {
24  j["strength"].get_to(s.strength);
25  j["agility"].get_to(s.agility);
26  j["intelligence"].get_to(s.intelligence);
27  j["physique"].get_to(s.physique);
28 }
29 
31  private:
32  static stats_t stats;
33  static std::unordered_map<race_type_t, std::string> race_names_map;
34  static std::unordered_map<race_type_t, nlohmann::json> race_modif_map;
35  static std::unordered_map<race_type_t, nlohmann::json> race_multi_map;
36 
37  static std::unordered_map<class_type_t, std::string> class_names_map;
38  static std::unordered_map<class_type_t, nlohmann::json> class_multi_map;
39  static bool race_exists(race_type_t race_type);
40  static bool class_exists(class_type_t class_type);
41 
42  public:
55  static void init(const char *stats_file, const char *races_file,
56  const char *classes_file);
57 
58  // Player race methods
65  static stats_t create_stats(race_type_t race_type);
66  static std::string get_race_name(race_type_t race_type);
67  static float get_race_hp_multiplier(race_type_t race_type);
68  static float get_race_mp_multiplier(race_type_t race_type);
69  static float get_regen_multiplier(race_type_t race_type);
70 
71  // Player class methods
72  static std::string get_class_name(class_type_t class_type);
73  static float get_class_hp_multiplier(class_type_t class_type);
74  static float get_class_mp_multiplier(class_type_t class_type);
75  static float get_meditate_multiplier(class_type_t class_type);
76 };
77 
78 #endif // ATTRIBUTE_MANAGER_H
AttributeManager::init
static void init(const char *stats_file, const char *races_file, const char *classes_file)
Se realiza la inicializacion de los diccionarios asociados a los modificadores de stats y multiplicad...
Definition: attribute_manager.cpp:23
AttributeManager::create_stats
static stats_t create_stats(race_type_t race_type)
Crea un stats_t decorado con la raza especificada.
Definition: attribute_manager.cpp:61
stats
Definition: attribute_manager.h:9
AttributeManager
Definition: attribute_manager.h:30