Argentum Online - Servidor
combat_component.h
1 #ifndef COMBAT_COMPONENT_H
2 #define COMBAT_COMPONENT_H
3 
4 #include <tuple>
5 
6 #include "../../../../include/nlohmann/json.hpp"
7 
8 typedef struct attack {
9  int damage;
10  bool crit;
11 } attack_t;
12 
13 typedef struct attack_result {
14  int damage_dealt;
15  bool dodged;
16  bool killed;
18 
20  protected:
21  unsigned int max_hp;
22  unsigned int max_mp;
23  unsigned int current_hp;
24  unsigned int current_mp;
25 
26  public:
27  CombatComponent(unsigned int max_hp, unsigned int max_mp);
28  CombatComponent(unsigned int max_hp, unsigned int max_mp,
29  unsigned int current_hp, unsigned int current_mp);
30  virtual ~CombatComponent();
31 
32  void reset_max(unsigned int max_hp, unsigned int max_mp);
33  unsigned int restore_hp(unsigned int hp);
34 
35  bool can_spend_mp(unsigned int mp);
36  void spend_mp(unsigned int mp);
37 
38  virtual attack_t attack() = 0;
39  virtual attack_result_t receive_damage(attack_t raw_damage) = 0;
40 
41  virtual void update(uint64_t) = 0;
42 
43  unsigned int get_max_hp() const;
44 
45  /* Devuelve true si esta listo para atacar. */
46  virtual bool attack_ready() const = 0;
47 
48  virtual nlohmann::json get_data() const;
49 
50  void set_max_mp(unsigned int mp);
51 
52  void set_max_hp(unsigned int hp);
53 };
54 
55 #endif // COMBAT_COMPONENT_H
attack_result
Definition: combat_component.h:13
attack
Definition: combat_component.h:8
CombatComponent
Definition: combat_component.h:19