Argentum Online - Servidor
item_factory.h
1 #ifndef ITEM_FACTORY_H
2 #define ITEM_FACTORY_H
3 
4 #include <map>
5 #include <unordered_map>
6 
7 #include "armor.h"
8 #include "gold.h"
9 #include "potion.h"
10 #include "special_ability.h"
11 #include "weapon.h"
12 
13 class ItemNotFoundException : public std::exception {
14  public:
15  const char* what() const throw();
16 };
17 
18 class ItemFactory {
19  private:
20  std::unordered_map<ItemId, item_type_t> id_to_type_map;
21  std::unordered_map<ItemId, Armor> armors_map;
22  std::unordered_map<std::string, nlohmann::json> abilities_map;
23  std::unordered_map<ItemId, Weapon> weapons_map;
24  std::unordered_map<ItemId, Potion> potions_map;
25  Gold _gold;
26 
27  void add_armors(const nlohmann::json& armors_data);
28 
29  void add_abilities(const nlohmann::json& abilities_data);
30 
31  void add_weapons(const nlohmann::json& weapons_data);
32 
33  void add_potions(const nlohmann::json& potions_data);
34 
35  SpecialAbility* create_ability(const std::string& ability_name);
36 
37  public:
38  ItemFactory(const char* items_file);
47  Item* create(ItemId item_id, uint32_t stack);
48  bool item_exists(ItemId item_id);
49  ~ItemFactory();
50 };
51 
52 #endif // ITEM_FACTORY_H
Item
Definition: item.h:45
SpecialAbility
Definition: special_ability.h:11
ItemFactory::create
Item * create(ItemId item_id, uint32_t stack)
Devuelve una copia del item en memoria, con su respectiva cantidad. En caso de no existir el item_id,...
Definition: item_factory.cpp:111
Gold
Definition: gold.h:6
ItemNotFoundException
Definition: item_factory.h:13
ItemFactory
Definition: item_factory.h:18