Argentum Online - Servidor
weapon.h
1 #ifndef WEAPON_H
2 #define WEAPON_H
3 
4 #include <string>
5 #include <vector>
6 
7 #include "../../../include/nlohmann/json.hpp"
8 #include "../map_log_factory.h"
9 #include "item.h"
10 #include "special_ability.h"
11 
12 typedef struct weapon_info {
13  uint16_t min_damage;
14  uint16_t max_damage;
15  float attack_speed;
16  std::string ability;
18 
19 inline void to_json(nlohmann::json& j, const weapon_info_t& w) {
20  j["min_damage"] = w.min_damage;
21  j["max_damage"] = w.max_damage;
22  j["attack_speed"] = w.attack_speed;
23  j["ability"] = w.ability;
24 }
25 
26 inline void from_json(const nlohmann::json& j, weapon_info_t& w) {
27  j["min_damage"].get_to(w.min_damage);
28  j["max_damage"].get_to(w.max_damage);
29  j["attack_speed"].get_to(w.attack_speed);
30  j["ability"].get_to(w.ability);
31 }
32 
33 class Weapon : public Item {
34  private:
36  SpecialAbility* special;
37 
38  public:
39  Weapon();
41  SpecialAbility* special, uint32_t stack = 0);
42 
43  Weapon(const Weapon& other, SpecialAbility* special);
44 
53  int deal_damage();
54 
61  std::vector<map_log_t> use_ability(Player* thrower, Entity* target,
62  position_t source, position_t dest);
63 
69  float get_attack_speed();
70 
71  nlohmann::json get_data() const override;
72  ~Weapon();
73 };
74 
75 #endif // WEAPON_H
Weapon
Definition: weapon.h:33
Item
Definition: item.h:45
Weapon::get_attack_speed
float get_attack_speed()
Devuelve el valor de la velocidad de ataque del arma.
Definition: weapon.cpp:30
SpecialAbility
Definition: special_ability.h:11
weapon_info
Definition: weapon.h:12
item_info
Definition: item.h:21
Weapon::use_ability
std::vector< map_log_t > use_ability(Player *thrower, Entity *target, position_t source, position_t dest)
Usar la habiliadad especial del arma.
Definition: weapon.cpp:23
Entity
Definition: entity.h:15
Weapon::deal_damage
int deal_damage()
Devuelve un valor en el rango de daƱo del arma.
Definition: weapon.cpp:18
Player
Definition: player.h:14
position
Definition: position.h:8